I hope the title gives enough description for the problem - here is some code and a plnk;
$(document).ready(function() {
$(document).on("change", '#selectCountry', function() {
alert("changed");
})
});
$("ul#countries li a").click(function() {
$("#selectCountry").html("")
$("#selectCountry").append($(this).html())
});
http://plnkr.co/edit/1MxnJmL3RlBeZy3pvPhH?p=preview
I've tried to read previous questions on here regarding a similar issue, but none of the solutions posted seemed to work for me. I'm hoping it's just a small thing I'm missing?
Thanks
remove this
$(document).ready(function() {
$(document).on("change", '#selectCountry', function() {
alert("changed");
})
});
change your click function like that
$("ul#countries li a").click(function() {
$("#selectCountry").html($(this).text())
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.