DIV onclick [英] DIV onclick
本文介绍了DIV onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个div标签,里面有一个锚标签.当我单击div标签时,我希望更改背景颜色和字体颜色.尽管我已经阅读了一些相关文章,但Iam无法获得有效的解决方案.
感谢任何帮助.谢谢大家.
Hi,
I have a div tag with an anchor tag within that. When I click on the div tag, I want the background colour and font colour to change. Although I have read a few posts on this, Iam unable to get a working solution.
Appreciate any help. Thank you all.
<div class="select" style="top: 224px"><a href="ATSSearch.aspx">Search Applications</a></div>
推荐答案
<head runat="server">
<title></title>
<script language="javascript">
function ChangeDiv(div) {
div.style.backgroundColor = '#cccccc';
document.getElementById("lnkSearch").style.color = "#000000";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div onclick="ChangeDiv(this)" class="select" style="top: 224px"><a href="#" id="lnkSearch">Search Applications</a></div>
</form>
</body>
这篇关于DIV onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文