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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將點(diǎn)擊功能從 <tr> 更改為 <td>

將點(diǎn)擊功能從 <tr> 更改為 <td>

慕村225694 2022-06-16 10:01:12
我正在嘗試使 html 頁(yè)面像圖書館一樣。在此用戶可以單擊評(píng)分按鈕,以便將所選書籍保存到本地存儲(chǔ),并且在打開該頁(yè)面時(shí)他們會(huì)獲得書籍評(píng)分。但問(wèn)題是:當(dāng)用戶單擊要閱讀的書名時(shí)(即整個(gè) tr,如果我們單擊 tr 中的任何位置),則無(wú)需專門單擊星號(hào)按鈕即可獲得評(píng)級(jí)。如何僅在我們單擊帶有星號(hào)按鈕的 td 時(shí)才對(duì)其進(jìn)行評(píng)分。. 我是 jquery 的新手。我從 stackoverflow 獲得了以下代碼。任何人都可以發(fā)布完整的 jquery 代碼,以便我可以了解兩個(gè)代碼的區(qū)別。我在下面發(fā)布整個(gè)代碼:<!DOCTYPE html><html><head>    <style>        img {            height: 25px;        }        .hide {            display: none;        }        .ratingTable { width: 400px; }        td {            cursor: pointer;        }        td[data-id] { width: 300px; }    </style>    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script></head><body> [<a href="comics.html">Comics</a>] [<a href="allbooks.html">All books</a>]<hr/>    <table class="ratingTable">        <tbody id="adventure">            <tr>                <td data-id="Book A">Adventure 1</td>                <td style="display:none" class="serial-code">book-dais</td>                <td>                    <div class="fav">                        <img class="white-star" src="https://i.postimg.cc/g0b9JG0w/unfav.png" />                        <img class="yellow-star hide" src="https://i.postimg.cc/QN1T9bSH/fav.png" />                    </div>                </td>            </tr>            <tr>                <td data-id="Book B">Adventure 2</td>                <td style="display:none" class="serial-code">book-jhon</td>                <td>                    <div class="fav">                        <img class="white-star" src="https://i.postimg.cc/g0b9JG0w/unfav.png" />                        <img class="yellow-star hide" src="https://i.postimg.cc/QN1T9bSH/fav.png" />                    </div>                </td>            </tr>
查看完整描述

1 回答

?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

在我讀了幾遍這個(gè)問(wèn)題之后,我想知道下面的話


但問(wèn)題是:當(dāng)用戶單擊要閱讀的書名時(shí)(即整個(gè) tr,如果我們單擊 tr 中的任何位置),則無(wú)需專門單擊星號(hào)按鈕即可獲得評(píng)級(jí)。


如何僅在我們單擊帶有星號(hào)按鈕的 td 時(shí)才對(duì)其進(jìn)行評(píng)分。


嘗試以下方式。


通過(guò)在帶有評(píng)級(jí)圖標(biāo)的表格列中添加一個(gè)虛擬 css 來(lái)稍微修改您的 html:

<td class="myratingSystem">

...

</td>

因?yàn)闆](méi)有定義 css 聲明,瀏覽器對(duì)這些標(biāo)簽不做任何事情。我經(jīng)常使用它來(lái)關(guān)注特定元素。


修改您的 jquery 腳本:

$(function() {

      $('td.myratingSystem').click(function(e) {

        //As is written into question the rest of the code snippet here is working 

        //as expected.

        ...

      });

}

您還必須更改以下幾行:


$(selector).closest("tr").trigger("click");



$(selector).parent().find("td.myratingSystem").trigger("click");


希望能幫助到你。


查看完整回答
反對(duì) 回復(fù) 2022-06-16
  • 1 回答
  • 0 關(guān)注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)