select option doesn't work separately

2019-08-27 02:38发布

In the given fiddle link, when I click on the green plus button in email or phone section it create a new input field.when I want to select an option from a dropdown menu it also select option in all dropdown menu.

*need to work dropdown menu separately.

*need to select radio button when click on text of dropdown menu.

Here is the JSFIDDLE link

2条回答
小情绪 Triste *
2楼-- · 2019-08-27 02:45

you have to use button tag next to ul to work, but I think this is wath you want!

$(document).on("click", 'a.radio_click', function(){
      var param = $(this).attr("href").replace("#","");
      var concept = $(this).text();
      var span = $(this).closest("ul").prev().find("span#search_concept");
      span.text(concept);
      $(this).find('input').prop('checked', true);
      $('.input-group #search_param').val(param);
});

you have to remove the

$('.search-panel .dropdown-menu').find('a').click(function() 

as it is unecessary.

查看更多
做个烂人
3楼-- · 2019-08-27 03:10

You use same id for both phone and email i.e "search_concept" use different id's and change code accordingly.

查看更多
登录 后发表回答