改变link标签的链接源就可以了,我以前写过的一个类似的,根据喜好选择不同的主题:
页面中引入了这样一个外部样式:
<link id="theme" href="themes/all-hallows-eve.css" rel="stylesheet" type="text/css">请选择主题:
<select id="sel1_tianlidong" onchange="changecss(this)"return false">
<option value="tricolore">tricolore主题</option>
<option value="twilight">twilight主题</option>
<option value="zenburnesque">zenburnesque主题</option>
</select>
脚本代码这样写:
<script>function changecss(obj)
{
document.getElementById("theme").href ="themes/"+obj.value+".css"
return false
}
</script>
$(".newItem a").hover(function(){$(this).css("color","red")//移入
},function(){
$(this).css("color","blue")//移出
})
是这样的效果吗?
你好,根据你的要求,我写了下面的范例代码,请参考:
<script type="text/javascript">//记得要先引入jQuery.js框架哦
$(document).ready(function(){
if($('.name').text().match('您好')){ //如果包含“您好”
$('.box').css('background','yellow') //box背景为黄色
}
if($('.name').text().match('再见')){ //如果包含“再见”
$('.box').css('background','red') //box背景为红色
}
})
</script>
附:完整的HTML范例代码,用浏览器打开即可看到效果。
如还有疑惑,欢迎追问。