在我的網站是有多個同名複選框的表單:問題與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