私は次のコードを使用しています:
$('#dataTable .select-topic')
.click(function () {
if ($(this).attr('data-list') == "N") {
$(this).attr('data-list', 'Y')
var topicSelectHtml = $('#TopicID')
.clone()
.find("optgroup:first").remove().end()
.find("option[value$='**']").remove().end().html();
$(this).html(topicSelectHtml);
$(this).attr('data-clicked', 'Y')
}
})
.change(function () {
$(this).attr("title", $("option:selected", this).text());
var type = $(this).attr('id').split('_')[1];
updateField(entity, $(this), type);
})
各行に選択があるため、数百行に適用されます。効率を上げるには、名前付き関数を作成し、それらをクリックアンドチェンジにアタッチする方がよいでしょう。もしそうなら、どうすれば上記のコードに対してこれを行うことができますか?