Get selected item value from Bootstrap DropDown with specific ID

前端 未结 7 766
鱼传尺愫
鱼传尺愫 2020-12-24 06:10

I am \"creating\" my own \"ComboBox\" using Bootstrap 3 and JavaScript. Here is the JSFiddle for what I have so far:

7条回答
  •  旧巷少年郎
    2020-12-24 06:50

    You might want to modify your jQuery code a bit to '#demolist li a' so it specifically selects the text that is in the link rather than the text that is in the li element. That would allow you to have a sub-menu without causing issues. Also since your are specifically selecting the a tag you can access it with $(this).text();.

    $('#datebox li a').on('click', function(){
        //$('#datebox').val($(this).text());
        alert($(this).text());
    });
    

提交回复
热议问题