怎么用js实现鼠标事件:点击鼠标显示A,但鼠标移开就不显示了A?
3个回答
展开全部
<a href="javascript:;" id="clickme" onclick="show();">点我</a>
<div id="showDiv" style="width:200px;height:200px;display:none;">
显示我
</div>
<script type="text/javascript">
function show(){
var clickElem = document.getElementById("clickme");
var showElem = document.getElementById("showDiv");
showElem.style.display = "block";
clickElem.onmouseleave = function() {
showElem.style.display = "none";
}
}
</script>
<div id="showDiv" style="width:200px;height:200px;display:none;">
显示我
</div>
<script type="text/javascript">
function show(){
var clickElem = document.getElementById("clickme");
var showElem = document.getElementById("showDiv");
showElem.style.display = "block";
clickElem.onmouseleave = function() {
showElem.style.display = "none";
}
}
</script>
展开全部
<span id="A">A</span>
<script>
var a = document.getElementById('A');
document.onmousedown = function () {
a.style.display = 'none'
}
document.onmouseup = function () {
a.style.display = ''
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
hover
onmouseover
onmouseout
onmouseover
onmouseout
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询