要素のクラス名を取得するには、this
のリファレンスを入手してください。 私はcompare-box
クラスにオブジェクトのクラス名を付加したいHTML要素にAddCompareOfferInCompareBox機能でjqueryの 'this'リファレンスのクラス名を取得する方法
<input type="checkbox" class="NotSelected @placeholderString" onchange="SaveCompairedOffers(this);">
jQueryのコード
function SaveCompairedOffers(obj) {
//Hiding irrelevant code from here
AddCompareOfferInCompareBox();
}
を次のようしています。
function AddCompareOfferInCompareBox()
{
var innerHtml = "";
$('.SelectedOffer').each(function()
//append class name of current passed object to this div
innerHtml = innerHtml + '<div class="compare-box"></div>';
});
$(".AddCompareOfferByMe").html(innerHtml);
}
どうすればいいですか?
このクラス名は?私は '@ placeholderString'と思いますか? – Satpal
@Satpalはい正確に –
$(this).attr( "class")はNotSelectedを返します@placeholderString – sarath