选择:contains
器是完美的选择。但是,在您的具体情况下,要使其发挥作用,还需要付出更多努力。在我的测试中,似乎是由于动态加载的外部脚本中的一些损坏的 URL,jQuery
或者$
是undefined
. jQuery
解决方法是在表(和其他外部脚本)加载后重新加载API。
[更新]
我正在重新发布.html
我认为它呈现正确结构的文件的全部内容(对我来说,它适用于 Chrome)。为了实现所需的字体颜色和 URL 格式,您仍然需要进行一些必要的修改,您可以通过jQuery
's.css()
函数来实现,如下所示。请注意:
- 我完全删除了
<style>...</style>
标签和
- 我在动态加载外部脚本之后调用's标记
waitForFnc
中的函数。<body>
<script>
对于需要水平滚动以查看完整jQuery
样式格式,我深表歉意,但它与解决方案并不真正相关,直到您想修改它时应用您自己的格式。
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var count=0;
function waitForFnc(){
if(typeof $ != "undefined")
{
if($("tr.bikram_yoga").length==0){
window.setTimeout(waitForFnc,50);
}
else
{
$(" div.healcode .header, div.healcode table.schedule tr th, div.healcode table.schedule tr.odd td, div.healcode table.schedule tr.even td").css("background-color","#f4f4f4");
$(".location, span.print_text, a.print_version, .mbo_class, span.day_links, .header, span.hc_date_year, div:nth-of-type(10), a[href*='100000210'], a[href*='/13/'], a[href*='100000242'], a[href*='100000201'], a[href*='/142/'], a[href*='100000174'], a[href*='100000229'], a[href*='100000053'],th.trainer").hide();
$("div.healcode").css("padding","20px 0 0 20px !important");
$("div.healcode span.hc_day").css({"margin-left": "0 !important",
"text-align": "left !important"});
$("div.healcode table.schedule").css("border","none !important");
$("table .schedule, tr schedule_header th").css("background-color","#f4f4f4");
$("tr.bikram_yoga").not(":contains('Marc')").hide();
}
}
else{
if(count==0){
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript= document.createElement("script");
oScript.type = "text/javascript";
oScript.src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
oHead.appendChild( oScript);
count=count+1;
}
window.setTimeout(waitForFnc,50);
}
}
</script>
</head>
<body>
<table>
<tr>
<td align="left" valign="top">
<div style="background-color: white;">
<script type="text/javascript">
id = "ki1120mmvd";
name = "schedules";
document.write(unescape("%3Cscript src='http://healcode.com/javascripts/hc_widget.js' type='text/javascript'%3E%3C/script%3E"));
waitForFnc();
</script>
<noscript class="normal_left_yellow">
Please enable Javascript in order to view the class schedule: <a href="http://healcode.com" target="_blank">HealCode</a>
</noscript>
</div>
</td>
</tr>
</table>
</body>
</html>