首页 > 解决方案 > 更新内容后 Javascript 功能不起作用(使用 Document Ready atm。)

问题描述

我有一个问题,我正在使用基于表单的购物车添加功能和实时搜索 (PHP) 功能,它请求具有相同类的新数据。除了(document.ready)之外,我还看到了多个示例,但是在 PHP livesearch 函数修改了 DOM 内容后,它们似乎都没有正常工作。(如你们所见,当前方法是在文档就绪功能上。

提前致谢!

// Icon Click Focus
$('.product').on('click', function() {
    var strId = '';
    var strId = $(this).attr('class');
    var strId2 = strId.replace(' product','');
    var strId3 = strId2.replace('product-','');
    var formData = "product"+strId3;
    
    document.getElementById("product_toevoeg_id").value = strId3;
    
    var productNaam = $("#"+formData+" .f-productnaam").val();
    document.getElementById("productnaam").innerHTML = productNaam;
    document.getElementById("product_naam_form").value = productNaam;
    
    var productIngredienten = $("#"+formData+" .f-ingredienten").val();
    document.getElementById("ingredienten").innerHTML = productIngredienten;
    document.getElementById("ingredienten_form").value = productIngredienten;

标签: javascriptdocumentlivesearchready

解决方案


推荐阅读