I'm using chosen JQuery plugin, i would like when the user click on the select box; do something (load data from data base into the select box).
HTML
<select name="mysection" id="mysection" class="chosen-select-deselect">
</select>
JS
$('#mysection').live('click',function(){
alert("hello for test");
})
I tried to just test if the event work or not, but it seems not working
NB: i'm using jquery 1.6.4
I'm using chosen JQuery plugin, i would like when the user click on the select box; do something (load data from data base into the select box).
HTML
<select name="mysection" id="mysection" class="chosen-select-deselect">
</select>
JS
$('#mysection').live('click',function(){
alert("hello for test");
})
I tried to just test if the event work or not, but it seems not working
NB: i'm using jquery 1.6.4
Share Improve this question asked Feb 17, 2014 at 15:28 MDITMDIT 1,5486 gold badges25 silver badges38 bronze badges 11- 1 I would remend you to upgrade to latest version of jQuery soon! – Chethan N Commented Feb 17, 2014 at 15:31
- What is your console saying? Any error log? Can you provide a fiddle, because this should work. And yeap you should update you jQuery library – Emil Borconi Commented Feb 17, 2014 at 15:32
- Upgrade to a newer jquery... Also, what does your console say? Is it showing any problems? – buzzsawddog Commented Feb 17, 2014 at 15:32
- @RobSchmuecker that wont work he is in 1.6.4 – buzzsawddog Commented Feb 17, 2014 at 15:33
- there is no problem in the console !! – MDIT Commented Feb 17, 2014 at 16:09
1 Answer
Reset to default 5While dealing with the selectmenus or check boxes use 'change
'.
here is the code
HTML
<select name="mysection" id="mysection">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
JS
$(document).ready(function () {
$("#mysection").chosen();
$('#mysection').live('change', function () {
alert($(this).val());
});
});
CSS
#mysection {
width: 100px;
}
Try the above code, it will work :)
EDIT
when you use chosen, it converts select into another div after it, you can even use
$("#mysection_chosen").bind("click", function ()
or
$("#mysection").next().bind('click', function ()
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744712636a4589432.html
评论列表(0条)