Get selected item value from Bootstrap DropDown with specific ID

前端 未结 7 802
鱼传尺愫
鱼传尺愫 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 07:06

    The selector would be #demolist.dropdown-menu li a note no space between id and class. However i would suggest a more generic approach:

    $(document).on('click', '.dropdown-menu li a', function() { $(this).parent().parent().parent().find('.datebox').val($(this).html()); });

    by using a class rather than id, and using parent().find(), you can have as many of these on a page as you like, with no duplicated js

提交回复
热议问题