在我的网站是有多个同名复选框的表单:问题与jQuery获得() -
<span class="selection"><input type="checkbox" name="product" value="Hard Enamel" />Hard Enamel</span>
<span class="selection"><input type="checkbox" name="product" value="Soft Enamel" />Soft Enamel</span>
<span class="selection"><input type="checkbox" name="product" value="Metal Relief" />Metal Relief</span>
<span class="selection"><input type="checkbox" name="product" value="Printed With Epoxy" />Printed With Epoxy</span>
在我的JavaScript,我给你这一个变量,并且有使用JQuery一个onclick功能。有了这个,我仍然可以运行JQuery函数没有问题,例如products.css("display","none")
工程。
但是,当试图选择products
内的特定复选框时,它会返回一个错误。
这里是我的JS:
var products = $("input[name=product]").click(function(){selectProduct()});
products.get(0).css("display","none");
以上不工作,我也得到了错误badges_calc.js:9TypeError: 'undefined' is not a function (evaluating 'products.get(0).css("display","none")')
我怎样才能解决这个问题?我很喜欢初学者。
干杯
作品,感谢您的快速响应! – user1952067