javascript - jQuery chosen - on click dont work - Stack Overflow

I'm using chosen JQuery plugin, i would like when the user click on the select box; do something (

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
 |  Show 6 more ments

1 Answer 1

Reset to default 5

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 ()

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744712636a4589432.html

相关推荐

  • javascript - jQuery chosen - on click dont work - Stack Overflow

    I'm using chosen JQuery plugin, i would like when the user click on the select box; do something (

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信