我正在编写一个插件,它将过滤“woocommerce_single_product_image_html”以显示产品的自定义图像。Woocommerce:产品变体的自定义图像
我无法通过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的核心变化事件相冲突。有关如何通过插件完成此任务的任何建议?