亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

嘗試將文本和圖像添加到 onmouseover

嘗試將文本和圖像添加到 onmouseover

九州編程 2022-06-16 10:57:08
我還是一個新手,正在嘗試將圖像添加到項目的描述中。理論上,當用戶將鼠標懸停在項目上時,旁邊的列中會顯示圖像和描述。我知道我在使用雙引號和單引號時做錯了什么,但我不確定它是什么。            function gettip(txt)            {                document.getElementById('info').innerHTML=txt;            }function reset(){    document.getElementById('info').innerHTML="Roll over a link for information on the project! "}<a href="Homework.html"                onmouseover="gettip('<img src='Images/homeworkpreview.jpg'><br><br><b>Due:</b> January 27 <br> <b>Points:</b> 50 <br> <br> <b> Description: </b> <br> Create a Homework page with a table with information about the projects for this semester. This will act as the hub for all of your projects to be linked to.')"                onmouseout="reset()"> Homework </a> 
查看完整描述

2 回答

?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

您可以使用反引號 (`),這將允許您在txt. 例如:gettip(`This 'string' can include "quotes"`)

對于您的情況:

onmouseover="gettip(`<img src='Images/homeworkpreview.jpg'><br><br><b>Due:</b> January 27 <br> <b>Points:</b> 50 <br> <br> <b> Description: </b> <br> Create a Homework page with a table with information about the projects for this semester. This will act as the hub for all of your projects to be linked to.`)"

注意:這適用于約 95% 的用戶。如果您需要更多報道,您可以按照此處的其他答案指示轉義引號。


查看完整回答
反對 回復 2022-06-16
?
米脂

TA貢獻1836條經驗 獲得超3個贊

轉義單引號后,您需要一些帶有 id 的元素info,例如:


function gettip(txt) {

  document.getElementById("info").innerHTML = txt;

}


function reset() {

  document.getElementById("info").innerHTML =

    "Roll over a link for information on the project! ";

}

<a href="Homework.html" onmouseover="gettip('<img src=\'Images/homeworkpreview.jpg\'><br><br><b>Due:</b> January 27 <br> <b>Points:</b> 50 <br> <br> <b> Description: </b> <br> Create a Homework page with a table with information about the projects for this semester. This will act as the hub for all of your projects to be linked to.')"

  onmouseout="reset()">

      Homework

    </a>

<div id="info"></div>


查看完整回答
反對 回復 2022-06-16
  • 2 回答
  • 0 關注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號