看來jQuery :contains
選擇器在IE8上不起作用。:在IE8上包含問題
請參閱IE下面的例子 - LIVE DEMO
JS:
$('table tr td:contains(" + ")').each(function(){
$(this).addClass('url');
});
看來jQuery :contains
選擇器在IE8上不起作用。:在IE8上包含問題
請參閱IE下面的例子 - LIVE DEMO
JS:
$('table tr td:contains(" + ")').each(function(){
$(this).addClass('url');
});
您需要的空間轉換在您的預扣稅爲HTML實體(
)
爲$('table tr td:contains(" + ")')
工作。 (同JS/CSS)
HTML:
<table>
<tr>
<td> + </td>
<td> 1 </td>
<td> 3 </td>
<td> 6 </td>
<td> 7 </td>
</tr>
</table>
但是它會失敗在現代的瀏覽器,因此該解決方案是,以取代實體爲這些瀏覽器。只要在這之前加上這個片段,它就可以完成這項工作。
if(!($.browser.msie && $.browser.version < 10)){
$('table tr td').each(function(){
$(this).html($(this).html().replace(/ /gi, ' '));
});
}
另一種更簡單的解決IE8 :contains
問題:
確保您不使用字符串的內部空間,如
$('table tr td:contains("+")')
將工作即使你的HTML有空格<td> + </td>
我看不到你的小提琴,因爲jsFiddle像往常一樣慢,但嘗試轉義'+',像這樣:'$('t能夠使用tr td:contains(「\ +」)')' –
@RoryMcCrossan - 它不會幫助使用轉義字符 – Varun
您首先告訴我們,帶空格的選擇器不起作用,您的更新告訴我們不要使用空格。這是什麼? –