Have a func that get clicked div id need to give next func this id instead "#dropdown1"
$(function() {
$('.drop-down-input').click(function() {
$elementid = this.id;
$elementid= "#" + elementid;
});
console.log($elementid);
$("#dropdown1").click(function() {
$("#dropdown1 .dropdown-list").show();
});
$("#dropdown1 .dropdown-list li").on('click', function(e) {
e.stopPropagation();
$("#dropdown1 .dropdown-list").hide().siblings().val($(this).html());
});
});
HTML:
<div id="dropdown1" class="styled-input-container drop-down-input">
<input id="simple_2" class="drop-down-select" placeholder="input text" type="text">
<ul class="dropdown-list">
<li>eeee</li>
<li>xxxx</li>
<li>xxxx</li>
<li>xsssxxx</li>
</ul>
</div>
Idea is that I can use this code again in another place. for examle use 2 dropdowns with different ID