第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

如何在 JavaScript 中獲取表格行的位置

如何在 JavaScript 中獲取表格行的位置

慕容3067478 2022-06-09 17:10:22
當用戶單擊它們時,我想在表格行周圍顯示一個矩形,但 top 和 left 屬性不返回任何內容。我的代碼:focusRect 的樣式:  #focusRect {            position:absolute;            visibility: visible;            border: 2px solid red;        }   <script type="text/javascript">        function moveFocus(obj) {            var fr = document.getElementById("focusRect");            fr.style.top = obj.style.top+"px";            fr.style.left = obj.style.left+"px";            fr.style.width = obj.offsetWidth+"px";            fr.style.height = obj.offsetHeight+"px";        }    </script>并在表 tr 標簽上:<tr onclick="moveFocus(this)"> <div id="focusRect"></div>注意:我不會在這里寫不必要的代碼
查看完整描述

2 回答

?
繁星淼淼

TA貢獻1775條經(jīng)驗 獲得超11個贊

“#”這是一個類。它不是元素或 id。它用于為您的 CSS 頁面設置樣式。要設置 id,您可以在 HTML 或 javascript 中執(zhí)行此操作。html:


id="fname"

javascript:


let text = document.createElement('p'); 

//notice that you are assigning this element to "text" and then setting it's id.

text.id = "cellText";

所以假設您將id設置為“focusRect”并將其分配給“rectang”(這樣let = document.getElementById("focusRect")您每次都可以通過rectang引用對象。(查找dom:文檔對象模型對您有幫助)。


rectang.style.border = "thick solid #0000FF"; 


查看完整回答
反對 回復 2022-06-09
?
一只斗牛犬

TA貢獻1784條經(jīng)驗 獲得超2個贊

<table>

  <tr onclick="myFunction(this)">

    <td>Click to show rowIndex</td>

  </tr>

  <tr onclick="myFunction(this)">

    <td>Click to show rowIndex</td>

  </tr>

  <tr onclick="myFunction(this)">

    <td>Click to show rowIndex</td>

  </tr>

  <tr onclick="myFunction(this)">

    <td>Click to show rowIndex</td>

  </tr>

</table>

function myFunction(x) {

  console.log("Row index is: " + x.rowIndex);

}


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

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號