私のページには、言語セレクタ オプションを含むドロップダウン メニューがあります。言語の選択時に、言語に応じてラベルとボタンの html を変更したいのですが? マイコード
var arr = [];
// gets all the ids starting with comp_
$('div[id^="comp_"]').each(function(){
arr.push(this.id);
labels = $(this).find('label');
buttons = $(this).find('button');
//get all labels inside the current div
$(labels,buttons).each(function(){
$(this).html("");
});
});
console.log(arr);
},
*問題 * ラベル要素の参照のみを変更し、ボタンの参照は変更しません。複数の要素の参照に対して関数を実行できますか?
これを行うと機能しますが、異なる参照に対して同じコードを繰り返したくありません
var arr = [];
// gets all the ids starting with comp_
$('div[id^="comp_"]').each(function(){
arr.push(this.id);
labels = $(this).find('label');
buttons = $(this).find('button');
//get all labels inside the current div
$(labels).each(function(){
$(this).html("");
});
$(buttons).each(function(){
$(this).html("");
});
});
console.log(arr);
},