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

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

更改同級隱藏TD中的輸入值

更改同級隱藏TD中的輸入值

PHP
RISEBY 2022-09-17 17:22:05
當我的刪除按鈕被點擊時,我想將“is_active”輸入的值從“是”更改為“否”。到目前為止,我試圖使用兄弟姐妹來嘗試選擇具有“active”類的輸入。沒有運氣。這是我的代碼:<script type="text/javascript">$(document).on("click", ".delete", function(){         if ($(this).parents('.idcheck').length){        $(this).siblings("td").next().find('.active').val('no');         $(this).parents("tr").hide();         }        else         {$(this).parents("tr").remove();        }        $(".add-new").removeAttr("disabled");    });</script>  <table class="table table-bordered">    <thead>        <tr>            <th>First Name</th>            <th>Last Name</th>            <th>County</th>            <th>Street</th>            <th>City</th>            <th>Ward</th>            <th>Precinct</th>            <th>Actions</th>        </tr>    </thead>
查看完整描述

1 回答

?
藍山帝景

TA貢獻1843條經驗 獲得超7個贊

我想通了,這是更新的代碼:


<script type="text/javascript">

$(document).on("click", ".delete", function(){


         if ($(this).parents('.idcheck').length){


        $(this).closest('tr').find('.active').val('no'); 

        $(this).parents("tr").hide();


         }

        else 

        {$(this).parents("tr").remove();

        }


        $(".add-new").removeAttr("disabled");


    });

</script>  


<table class="table table-bordered">

    <thead>

        <tr>

            <th>First Name</th>

            <th>Last Name</th>

            <th>County</th>

            <th>Street</th>

            <th>City</th>

            <th>Ward</th>

            <th>Precinct</th>

            <th>Actions</th>

        </tr>

    </thead>

    <tbody>

    <form id="" class="form" name="parts" method="post" action="">

    <tr class="idcheck">

        <td style="display:none;"><input type="hidden" class="form-control" name="username" id="username" value="user"></td>

        <td><input type="text" class="form-control" name="first_name" id="first_name" value="John"></td>

        <td><input type="text" class="form-control" name="last_name" id="last_name" value="Doe"></td>

        <td><input type="text" class="form-control" name="county" id="county" value="my county"></td>

        <td><input type="text" class="form-control" name="street" id="street" value="456 easy street"></td>

        <td><input type="text" class="form-control" name="city" id="city" value="town"></td>

        <td><input type="text" class="form-control" name="ward" id="ward" value="5"></td>

        <td><input type="text" class="form-control" name="precinct" id="precinct" value="2"></td>

        <td style="display:none;"><input type="hidden" class="form-control" name="id" id="id" value="1"></td>

        <td style="display:none;"><input type="hidden" class="form-control active" name="is_active" id="is_active" value="yes"></td>

        <td><a class="delete" title="" data-toggle="tooltip" data-original-title="Delete"><i class="material-icons">?</i></a>

        </td>

    </tr>

    </tbody>

</table>

我把這行改成了:


$(this).siblings("td").next().find('.active').val('no');

對此:


$(this).closest('tr').find('.active').val('no');


查看完整回答
反對 回復 2022-09-17
  • 1 回答
  • 0 關注
  • 102 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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