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

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

從表中訪問點擊事件的數(shù)據(jù)

從表中訪問點擊事件的數(shù)據(jù)

PHP
冉冉說 2022-01-14 17:03:23
我有表“登錄”并使用 php 將 mysql 中的數(shù)據(jù)列出到 html 中的表中。<table class="table">                            <thead class="thead-dark">                            <tr>                                <th scope="col">Sl.NO</th>                                <th scope="col">Name</th>                                <th scope="col">Username</th>                                <th scope="col">Mobile</th>                                <th scope="col">Join Date</th>                                <th scope="col">Action</th>                            </tr>                            </thead>                            <tbody>                                <?php                                if($req_result->num_rows > 0)                                    {                                        while($req_row = $req_result->fetch_assoc()) {                                            $i+=1;                                            $reqmail = $req_row['username'];                                            $reqmobile = $req_row['id'];                                            $reqname = $req_row['name'];                                            $join_date = $req_row['join_date'];                                            ?>我想在點擊時訪問該按鈕值,并處理另一個查詢。tbale“登錄”有多個數(shù)據(jù)。我該怎么做?
查看完整描述

2 回答

?
忽然笑

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

由于表格中有多行,因此生成的 HTML 中有多個按鈕,您需要使用一種方法來捕獲對要分配事件偵聽器的所有元素的引用 - 除非您選擇使用event delegation但在這種情況下存在沒有必要這樣做。document.querySelectorAll在 vanilla javascript 中捕獲對按鈕的引用似乎很合適 - 并且為了便于forEach在某些瀏覽器中nodelist使用document.querySelectorAll轉(zhuǎn)換為數(shù)組的按鈕。


每個按鈕都被分配了一個匿名(在這種情況下無論如何)函數(shù)來處理click事件 -this匿名函數(shù)中的值是指允許輕松訪問其任何屬性的按鈕 - 這里只是value感興趣


let col=Array.prototype.slice.call( document.querySelectorAll( 'td > input[type="submit"]' ) );

    col.forEach( input =>{

        input.addEventListener('click',function(event){

            alert( 'Value: '+this.value );

        });

    });


查看完整回答
反對 回復(fù) 2022-01-14
?
翻過高山走不出你

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

嘗試使用這個。如果出現(xiàn)問題,請告訴我。干杯


//catch html button with js assigned to variable button

let button = document.querySelector('.btn btn-primary');


//listen for the click

button.addEventListener('click', function(){

   button.value;

});

// console log the the value of button

console.log(button);


查看完整回答
反對 回復(fù) 2022-01-14
  • 2 回答
  • 0 關(guān)注
  • 114 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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