【发布时间】:2014-04-07 11:47:31
【问题描述】:
我正在编写一个插件,该插件将过滤“woocommerce_single_product_image_html”以显示产品的自定义图像。
我无法通过 jquery 获取下拉框的值。到目前为止,我已经尝试过:
jQuery(document).ready(function($) {
// Code here will be executed on document ready. Use $ as normal.
$('#color').change(function() {
var selected = $(this).children("option").filter(":selected").text();
alert(selected);
});
});
我已经能够通过附加“.change()”来验证上述代码是否可以在加载时触发更改事件,但在更改下拉框中的选择时不会触发。我的猜测是,这与来自 woocommerece 的核心更改事件相冲突。关于如何通过插件完成此任务的任何建议?
【问题讨论】:
标签: jquery wordpress woocommerce