javascript - 更新内容后 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;
解决方案
推荐阅读
- node.js - Web3 不会在 Azure 上编译
- android - Android Studio 更新房间数据库中的数据
- nginx - 如何使用 Nginx 重定向编码的 url slug
- machine-learning - 5 epoch 太快让模型收敛?
- appium - 在 Appium 中切换上下文后无法选择 WebView 元素
- google-sheets - 如何在 ARRAYFORUMULA 的 SUMIF 中使用 ABS
- python - 是否有用于从字典格式的数据框的列中查找数据框的 Python 解决方案?
- android - 无法在 main-dex 文件中放置请求的类(#方法:73539 > 65536)
- turbolinks - 对特定页面仅使用一次 turbolinks:load 事件?
- django - 覆盖 django - 奥斯卡支付