私のサイトには、同じ名前のチェックボックスが複数あるフォームがあります。
<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")')
どうすればこれを修正できますか? 私はどちらかというと初心者です。
乾杯