Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更改同级隐藏TD中输入的值_Javascript_Php_Jquery_Siblings - Fatal编程技术网

Javascript 更改同级隐藏TD中输入的值

Javascript 更改同级隐藏TD中输入的值,javascript,php,jquery,siblings,Javascript,Php,Jquery,Siblings,单击“删除”按钮时,我想将“是活动的”输入的值从“是”更改为“否”。 到目前为止,我尝试使用兄弟姐妹来尝试选择“active”类的输入。不走运 这是我的密码: <script type="text/javascript"> $(document).on("click", ".delete", function(){ if ($(this).parents('.idcheck').length){ $(this).siblings("td").ne

单击“删除”按钮时,我想将“是活动的”输入的值从“是”更改为“否”。 到目前为止,我尝试使用兄弟姐妹来尝试选择“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>
    <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>

$(文档)。在(“单击“,”.delete“,函数()上){
if($(this).parents('.idcheck').length){
$(this).this(“td”).next().find('.active').val('no');
$(this.parents(“tr”).hide();
}
其他的
{$(this.parents(“tr”).remove();
}
$(“.add new”).removeAttr(“禁用”);
});
名字
姓
县
大街
城市
病房
警区
行动


我想出来了,下面是更新后的代码:

<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).closest('tr').find('.active').val('no');

尝试发布更容易阅读的Html代码,我更新了它,使其更容易阅读。
$(this).closest('tr').find('.active').val('no');