<a href="javascript:search()" onclick="">查询</a>
要写在onclick中不需要javascript指令
<a href="#" onclick="search()return false">查询</a>
以下使用JQUERY插件的<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#links a").click(function(){
$("#links a").each(function(i,dom){
$(dom).removeAttr("style")
})
$(this).attr("style","background-color:#F00")
})
})
</script>
<body>
<div id="links">
<a href="javascript:">1111111</a><br />
<a href="javascript:">2222222</a><br />
<a href="javascript:">3333333</a><br />
<a href="javascript:">4444444</a><br />
<a href="javascript:">5555555</a><br />
<a href="javascript:">6666666</a><br />
<a href="javascript:">7777777</a><br />
<a href="javascript:">8888888</a><br />
</div>
</body>
</html>
欢迎分享,转载请注明来源:优选云