【问题标题】:How to use .on() using querySelector in jquery?如何在 jquery 中使用 querySelector 使用 .on()?
【发布时间】:2020-11-29 17:45:44
【问题描述】:

我想用querySelector方法重写下面的jquery代码

<script type="text/javascript">
jQuery(function($){
    $('#woocommerce-product-data').on('woocommerce_variations_loaded', function() {
        $(this).find('.woocommerce_variation').each(function() {

       });
    });

});
</script>

【问题讨论】:

    标签: javascript jquery wordpress woocommerce jquery-selectors


    【解决方案1】:

    const EL_wc_pdata = document.querySelector("#woocommerce-product-data");
    EL_wcp_data.addEventListener("woocommerce_variations_loaded", function() {
      const ELs_wc_var = EL_wc_pdata.querySelectorAll(".woocommerce_variation");
      ELs_wc_var.forEach(el => {
        // el.
      });
    });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多