Javascript 使用JQuery在HTML字段中获取数据信息
我有一个用数据属性计算的自动字段,但我不能使用该字段,所以我想用Jquery复制功能,我想用一个按钮用Jquery函数来实现这一点,并填充一个文本字段 最初,我有这样的想法:Javascript 使用JQuery在HTML字段中获取数据信息,javascript,jquery,custom-data-attribute,Javascript,Jquery,Custom Data Attribute,我有一个用数据属性计算的自动字段,但我不能使用该字段,所以我想用Jquery复制功能,我想用一个按钮用Jquery函数来实现这一点,并填充一个文本字段 最初,我有这样的想法: <input type="radio" name="radio-1" value="female" id="forminator-field-radio-1-2-608c8cfc0bc56" data-calculation="
<input type="radio" name="radio-1" value="female" id="forminator-field-radio-1-2-608c8cfc0bc56" data-calculation="0">
还有几个像以前一样,
然后,自动填充字段具有:
<input type="number" name="calculation-1" value="" id="calculation-1-field" class="test-calculation" data-formula="({radio-1} * (10*{number-2} + 6.25*{number-3}) * {number-2})" data-required="" data-precision="0" data-is-hidden="" disabled="disabled">
但是,我希望JQuery中的按钮可以执行类似的操作,但它不起作用:
<script>
$(document).on('click','#calculatecal',function(){
$("#caloryid h3").html({radio-1});
});
</script>
$(文档).on('click','#calculatecal',函数(){
$(“#caloryid h3”).html({radio-1});
});
脚本没有得到radio-1,我如何查询数据?数据计算或如何模拟数据公式
谢谢,嗨,我不明白你的意思,但也许你在找这个
<script>
$(document).on('click','#calculatecal',function(){
$("#caloryid h3").html({radio-1} * (10*{number-2} + 6.25*{number-3});
});
</script>
$(文档).on('click','#calculatecal',函数(){
$(“#caloryid h3”).html({radio-1}*(10*{number-2}+6.25*{number-3});
});
hi,感谢您的回复,但是,在“数据公式”中,它了解什么是radio 1,但在它之外,它不了解,这就是为什么我想知道是否有任何命令,以便我可以使用“radio 1”,而无需向每个元素添加一个额外的类,并使用jquery(如$(id))来查找它。您是否在寻找$('td[name=“radio-1”]“)//完全匹配“radio-1”
$('td[name^=“radio”])//匹配以“radio”开头的('td[name$=”-1“])//匹配以“-1”结尾的('td[name*=”radio“])//匹配包含“radio”的