課程
/前端開發
/JavaScript
/JavaScript入門篇
3-5中如何通過鼠標懸停 來實現隱藏和現實內容 是用hover么 要該怎么結合使用 謝謝啦!
2016-05-01
源自:JavaScript入門篇 3-5
正在回答
通過更改display標簽以及onmuose和onmouseout事件實現,具體操作:
<!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" xml:lang="en">
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
? ? ? ? <title>test13</title>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? window.onload = function(){
? ? ? ? ? ? ? ? var a = document.getElementById("hover");
? ? ? ? ? ? ? ? var t = document.getElementById("text");
? ? ? ? ? ? ? ? ? ? a.onmouseover = function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? t.style.display = "none"; ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ?a.onmouseout = function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? t.style.display = "block"; ? ? ? ? ??
? ? ? ? ? ? }
? ? ? ? </script>
? ? </head>
? ? <body>
? ? ? ??
? ? ? ? <a href="#" id="hover">hover</a>
? ? ? ? <p id="text" style="display: block">隱藏這段文字</p>
? ? </body>
</html>
linkbb 提問者
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
1 回答實現隱藏顯示
4 回答顯示和隱藏是實現不了
2 回答無法實現顯示和隱藏功能
2 回答為何點擊隱藏內容和顯示內容沒反應
3 回答為何顯示內容.隱藏內容和取消設置無效
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-05-01
通過更改display標簽以及onmuose和onmouseout事件實現,具體操作:
<!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" xml:lang="en">
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
? ? ? ? <title>test13</title>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? window.onload = function(){
? ? ? ? ? ? ? ? var a = document.getElementById("hover");
? ? ? ? ? ? ? ? var t = document.getElementById("text");
? ? ? ? ? ? ? ? ? ? a.onmouseover = function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? t.style.display = "none"; ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ?a.onmouseout = function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? t.style.display = "block"; ? ? ? ? ??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? </script>
? ? </head>
? ? <body>
? ? ? ??
? ? ? ? <a href="#" id="hover">hover</a>
? ? ? ??
? ? ? ? <p id="text" style="display: block">隱藏這段文字</p>
? ? </body>
</html>