0
У меня есть следующий код jQuery.разделительный текст в jquery
innerHtml = innerHtml + '<div class="compare-box '+ $(this).attr("offertype") +'"> <div class="compare-close"><span class="closed" onclick="RemoveCompareOffer(\''+ $(this).attr("id") + '\')"><i class="fa fa-times"></i></span></div>'
+ '<div class="compare-logo"><img src="' + $(this).attr("imagelink") + '" /></div><p>' + $(this).attr("offername") + '</p>'
+ '<input type="button" value="View Details" class="viewbtn" onclick="CallOfferRenderAction(\'' + $(this).attr("offercode") + '\',\'' + $(this).attr("providercode") + '\')" /></div>';
Всякий раз, когда $(this).attr("offertype")
содержит special-box specialoffer
Я хочу, чтобы разделить и заменить его specialoffer-compare
. Как я могу это сделать?
, что и хотят разделить и заменить, с которой струна специальный ящик или specialoffer –
Я хочу, чтобы удалить специальный ящик , сохраняйте специальное предложение и добавляйте '-compare' к specialoffer –
использовать переменную, как показано ...' var temp = $ (this) .attr ("offertype"); temp = temp.indexOf ("special-box specialoffer")> -1? «specialoffer-compare»: temp; innerHtml = innerHtml + ... + temp + .... ' –