[英]Invoking a Select HTML Element OnChange Event from jQuery
I have a requirement that when I click a DIV I should trigger the Select HTML Element onChange event. 我有一个要求,当我单击DIV时应触发Select HTML Element onChange事件。
<select name="SWF_2_FauxColors_Reg" onchange="show_product_1(this)" />
I can access the select from inside the DIV event but when I do the following: 我可以从DIV事件内部访问选择,但是当我执行以下操作时:
var select = $(this); // where $(this) is a select html list
myDiv.click(function(){
select.val($(this).attr("id")).change();
});
But the above does not trigger the show_product_1(this) event. 但是以上内容不会触发show_product_1(this)事件。 I cannot call the show_product_1(this) directly since it is dynamically inserted into the select html list.
我无法直接调用show_product_1(this),因为它已动态插入到html列表中。
尝试使用jquery .trigger()函数:
select.trigger("onchange");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.