思路:
用js给DOM赋值,
用js修改DOM的样式。
代码如下,仅供参考:
<body><div style="width:100px height:100px background:#ccc"></div>
</body>
<script>
var oDiv = document.getElementsByTagName('div')[0]
oDiv.innerHTML = '这是关键字'
oDiv.style.color = 'red' //修改样式
</script>
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<script>
window.onload=function(){
var href=window.location.href
var tdArr=document.querySelector("table tr").children
if(/aaa/i.test(href)){
tdArr[0].innerHTML="a"
tdArr[0].style.background="red"
}
if(/bbb/i.test(href)){
tdArr[1].innerHTML="b"
tdArr[1].style.background="red"
}
if(/ccc/i.test(href)){
tdArr[1].innerHTML="c"
tdArr[1].style.background="red"
}
if(/ddd/i.test(href)){
tdArr[1].innerHTML="d"
tdArr[1].style.background="red"
}
}
</script>
</head>
<body>
<table>
<tr>
<td>内容1</td>
<td>内容2</td>
<td>内容3</td>
<td>内容4</td>
</tr>
</table>
</body>
</html>