我有两个矩形,里面有一些文本。我想在单击每个警报时显示不同的警报,但下面的代码不起作用(不显示警报)。有任何想法吗?谢谢
<div id="panel0" style="width: 100%">
<div class="titleBox" id="rect0" onclick="alert('yeah1');"
style="height: 85px; width: 85px;">Hello</div>
<div class="titleBox" id="rect1" onclick="alert('yeah2');"
style="height: 85px; width: 85px;">Hello</div>
</div>
最佳答案
试试这个
<div id="rect0" onclick="alert('yeah1');" style="height: 85px; width: 85px; background-color: #ff0000;">
Hello
</div>
关于javascript - DIV的onclick中的alert()点击后不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10649264/