私は限られた JQuery の知識で壁にぶつかりました。いくつかのチェックボックスを使用しています。
<input id="e_1" class="hiders" type="checkbox">
<label for="e_1">Hide Element 1</label>
<input id="e_2" class="hiders" type="checkbox">
<label for="e_2">Hide Element 2</label>
//Currently 6 of the above, with unique id's and shared class
関連するdivを非表示にするユニバーサル(および再利用可能な関数)を作成したい:
<div id="e_1_div"> content </div>
<div id="e_2_div"> content </div>
//Currently 6 of the above, with unique id's and shared class
次の解決策は、私が現在使用しているものです (チェックボックスごとに個別の関数を使用)。私の限られた知識から、それはひどく不正な形式であり、おそらく不要な電力も大量に消費していることがわかります。
$('#e_1').change(function(){
$('#e_1_div').toggle();
});
$('#e_2').change(function(){
$('#e_2_div').toggle();
});
だから私の質問:どこから始めればいいですか?このような再利用可能な関数の作成について、どこで詳しく知ることができますか? または、本当に私を甘やかしたい場合、考えられる解決策またはヒントは何ですか?
時間をありがとう、ドラガン