Reputation: 1548
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
Upvotes: 2
Views: 7303
Reputation: 1424
While 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 ()
Upvotes: 5