I want to trigger .change() on select, if I change option in select element by code.
I take example from jQuery documentation and added my hook to link, which after click change selected option in select. And problem is if user click on that link, then change function doesn't react.
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("div").text(str);
})
.change();
$("#test").click(function () {
$("select option:eq(2)").attr("selected", "selected")
});