[英]:contains issue on IE8
You need to convert the spaces in your TDs to HTML entities (
) 您需要将TD中的空格转换为HTML实体(
)
for $('table tr td:contains(" + ")')
to work. for
$('table tr td:contains(" + ")')
工作。 (Same JS/CSS) (相同的JS / CSS)
HTML: HTML:
<table>
<tr>
<td> + </td>
<td> 1 </td>
<td> 3 </td>
<td> 6 </td>
<td> 7 </td>
</tr>
</table>
However it will fail on modern browsers, so the solution is to replace the entities for those browsers. 但是它会在现代浏览器上失败,因此解决方案是替换这些浏览器的实体。 Just prepend this snippet before yours, it will do the job.
只需将此代码段添加到您的代码之前,它就能完成这项工作。
if( !($.browser.msie && $.browser.version < 10) ){
$('table tr td').each(function(){
$(this).html( $(this).html().replace(/ /gi, ' ') );
});
}
Another simpler solution to the IE8 :contains
issue: IE8 :contains
另一个更简单的解决方案IE8 :contains
问题:
Make sure you are not using the space inside the string, eg 确保您没有使用字符串中的空格 ,例如
$('table tr td:contains("+")')
will work even if your html have spaces <td> + </td>
$('table tr td:contains("+")')
会工作 ,即使你的HTML有空格<td> + </td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.