When the delete button is clicked, how to get the value whose td is Zhang San

< tr >

                  <td>10000</td>
                  <td></td>
                  <td></td>
                  <td>1327899099</td>
                  <td>500</td>
                  <td class="center ">
                    <a href="-sharp" class="btn btn-info"></a>
                    <a href="-sharp" class="btn btn-danger" onclick="deleteUser(this);"></a>
                </td>
              </tr>
              
              <script>

function deleteUser(obj){
    //
}

< / script >

Mar.18,2021

function deleteUser(obj) {
    let val = $(obj).parent().parent().children('td:eq(1)')[0].innerHTML
    console.log(val) // ""
}

<table>
    <tr>
        <td>10000</td>
        <td class="dataName" data-name=""></td>
        <td></td>
        <td>1327899099</td>
        <td>500</td>
        <td class="center">
            <a href="-sharp" class="btn btn-info"></a>
            <a href="-sharp" class="btn btn-danger" onclick="deleteUser(this);"></a>
        </td>
    </tr>
</table>
<script src="assets/lib/jquery-1.11.3.min.js"></script>
<script>
    function deleteUser(obj){
        console.log($(obj).parent().siblings('.dataName').attr('data-name'))
    }
</script>

the advantage of writing in this way is that it can be used even if td, is added later, and .data (), can be used to cache data to a certain extent


$(obj).). Html () ('tr'). Find (' td:eq (1)'). Html ()

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34795-2bf2f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34795-2bf2f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?