Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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 jquery隐藏和显示错误_Javascript_Jquery_Html - Fatal编程技术网

Javascript jquery隐藏和显示错误

Javascript jquery隐藏和显示错误,javascript,jquery,html,Javascript,Jquery,Html,我有一个表,有3个选项,其中两个是隐藏的,一个在开头,根据选项的不同,我使用a。js调用操纵来创建表中的新行,还使用会计将其添加到select的id中,并避免相同的调用,问题是当我创建新行而不是更改请求时,不会标记bug,只是什么也不做 这是我的密码 code html <script> $(document).ready(function () { $("#estado").change(function () { if

我有一个表,有3个选项,其中两个是隐藏的,一个在开头,根据选项的不同,我使用a。js调用操纵来创建表中的新行,还使用会计将其添加到select的id中,并避免相同的调用,问题是当我创建新行而不是更改请求时,不会标记bug,只是什么也不做 这是我的密码

code html

 <script>    
    $(document).ready(function () {
        $("#estado").change(function () {
            if ($("#estado").val() == 2) {
                $("#sino").show();
                $("#sexo").hide();            
            }
            if ($("#estado").val() == 3) {
                $("#sino").hide();
                $("#sexo").show();
            }
    </script>
    <td>
    <select id="estado">
    <option value="1">Seleccione 1 opcion</option>
    <option value="2">Laboratorio</option>
    <option value="3">Datos Generales</option>
    </select>
    </td>
    //laboratorio
    <select name="sino" id="sino"style="display:none">
    <option value="1">Si </option>
    <option value="2">No</option>
    </select>
    datos generales
    <select name="sexo" id="sexo"  style="display:none">
    <option value="1">Masculino </option>
    <option value="2">Femenino</option>
    </select>
code html
$(文档).ready(函数(){
$(“#estado”)。更改(函数(){
if($(“#estado”).val()==2){
$(“#sino”).show();
$(“#sexo”).hide();
}
if($(“#estado”).val()==3){
$(“#sino”).hide();
$(“#sexo”).show();
}
选择1选项
实验室
拿督属
//实验室
硅
不
拿督属
男性的
女性
codigo.js

//manipulacion 
var cont=1
    $(document).ready(function () {
        $("#estado"+cont).change(function () {      
            if ($("#estado"+cont).val() == 2) {
                $("#sino"+cont).show();
                $("#sexo"+cont).hide();       
            }
            if ($("#estado"+cont).val() == 3) {
                $("#sino"+cont).hide();
                $("#sexo"+cont).show();
            } );
            var strNueva_Fila = '<tr>' +
'<td><label>Area Medica</label></td>' +
'<td><select id="estado' + cont +'"><option value="1">Seleccione 1 opcion</option><option value="2">Laboratorio</option><option value="3">Datos Generales</option><select></td>' +
'<td><select name="sino" id="sino'+cont'"style="display:none"><option value="1">Si </option><option value="2">No</option></select></td>' +
'<td id="columna1' + cont + '" ><select name="sexo'+cont'" id="sexo"  style="display:none"><option value="1">Masculino </option><option value="2">Femenino</option></select>'+
'<td><input type="button" value="+" class="clsAgregarFila"><input type="button" value="-" class="clsEliminarFila"></td>' +
'</tr>';
        cont++;
        var objTabla = $(this).parents().get(3);     
        $(objTabla).find('tbody').append(strNueva_Fila);      
        if (!$(objTabla).find('tbody').is(':visible')) {          
          $(objTabla).find('caption').click();
        }
    });
    $(document).on('click', '.clsEliminarFila', function () {     
       var objCuerpo = $(this).parents().get(2);
        if ($(objCuerpo).find('tr').length == 1) {
            if (!confirm('Esta es el única fila de la lista ¿Desea eliminarla?')) {
                return;
            }
        }      
        var objFila = $(this).parents().get(1);      
        $(objFila).remove();
    });
            );
//操作
var cont=1
$(文档).ready(函数(){
$(“#estado”+cont).change(函数(){
如果($(“#estado”+cont).val()==2){
$(#sino+cont).show();
$(“#sexo”+cont.hide();
}
如果($(“#estado”+cont).val()==3){
$(#sino+cont).hide();
$(“#sexo”+cont.show();
} );
var strNueva_Fila=“”+
“区域医疗”+
“Seleccione 1 opcionLaboratorioDatos Generales”+
“没有”+
“男性女性”+
'' +
'';
cont++;
var objTabla=$(this.parents().get(3);
$(objTabla).find('tbody').append(strNueva_Fila);
if(!$(objTabla).find('tbody').is(':visible'){
$(objTabla.find('caption')。单击();
}
});
$(document).on('click','.clsEliminarFila',函数(){
var objCuerpo=$(this.parents().get(2);
if($(objCuerpo).find('tr')。长度==1){
如果(!确认('Esta es elúnica fila de la lista?Desea eliminarla?')){
返回;
}
}      
var objFila=$(this.parents().get(1);
$(objFila.remove();
});
);

看这里是像html一样的完整代码。js只是一个复制和粘贴的问题,如果我明白我想做的是,当一个新行出现时,我会做第一个更改,如果你意识到,当你添加一行时,什么也不做

html


$(文档).ready(函数(){
$(“#estado”)。更改(函数(){
if($(“#estado”).val()==2){
$(“#sino”).show();
$(“#sexo”).hide();
}
if($(“#estado”).val()==3){
$(“#sino”).hide();
$(“#sexo”).show();
}
});
});
选择1选项
实验室
拿督属
硅
不
男性的
女性
manipulacion.js

//manipulacion 
var contLin=1
    $(document).ready(function () {
        $("#estado"+contLin).change(function () {      
            if ($("#estado"+contLin).val() == 2) {
                $("#sino"+contLin).show();
                $("#sexo"+contLin).hide();       
            }
            if ($("#estado"+contLin).val() == 3) {
                $("#sino"+contLin).hide();
                $("#sexo"+contLin).show();
            }
}           );



});


$(document).ready(function(){
    //evento que se dispara al hacer clic en el boton para agregar una nueva fila
    $(document).on('click','.clsAgregarFila',function(){
        //almacenamos en una variable todo el contenido de la nueva fila que deseamos
        //agregar. pueden incluirse id's, nombres y cualquier tag... sigue siendo html

        var strNueva_Fila='<tr>'+
'<td><select id="estado'+contLin+'"><option value="1">Seleccione 1 opcion</option><option value="2">Laboratorio</option><option value="3">Datos Generales</option></select></td>' +
'<td><select name="sino'+contLin+'" id="sino"style="display:none"><option value="1">Si </option><option value="2">No</option></select></td>'+
'<td> <select name="sexo'+contLin+'" id="sexo"  style="display:none"><option value="1">Masculino </option><option value="2">Femenino</option></select><td>'+
'<td><input type="button" value="+" class="clsAgregarFila"><input type="button" value="-" class="clsEliminarFila"></td>'+
'</tr>';

contLin++;

        var objTabla=$(this).parents().get(3);


        $(objTabla).find('tbody').append(strNueva_Fila);


        if(!$(objTabla).find('tbody').is(':visible')){

            $(objTabla).find('caption').click();
        }
    });


    $(document).on('click','.clsEliminarFila',function(){

        var objCuerpo=$(this).parents().get(2);
            if($(objCuerpo).find('tr').length==1){
                if(!confirm('Esta es el única fila de la lista ¿Desea eliminarla?')){
                    return;
                }
            }


        var objFila=$(this).parents().get(1);

            $(objFila).remove();
    });



});
//操作
var contLin=1
$(文档).ready(函数(){
$(“#estado”+contLin).change(函数(){
if($(“#estado”+contLin).val()==2){
$(#sino+contLin).show();
$(“#sexo”+contLin).hide();
}
if($(“#estado”+contLin).val()==3){
$(#sino+contLin).hide();
$(“#sexo”+contLin).show();
}
}           );
});
$(文档).ready(函数(){
//在新的一年中发生的事件
$(文档).on('click','.clsAgregarFila',函数(){
//我们的生活充满变数,我们的生活充满变数
//agregar.pueden包括id、名称和cualquier标记…sigue siendo html
var strNueva_Fila=“”+
“Seleccione 1 opcionLaboratorioDatos Generales”+
“没有”+
“男性女性”+
''+
'';
contLin++;
var objTabla=$(this.parents().get(3);
$(objTabla).find('tbody').append(strNueva_Fila);
if(!$(objTabla).find('tbody').is(':visible')){
$(objTabla.find('caption')。单击();
}
});
$(文档).on('单击','.clsEliminarFila',函数(){
var objCuerpo=$(this.parents().get(2);
if($(objCuerpo).find('tr')。长度==1){
如果(!确认('Esta es elúnica fila de la lista?Desea eliminarla?')){
返回;
}
}
var objFila=$(this.parents().get(1);
$(objFila.remove();
});
});

您没有包含足够的代码来提供帮助。您应该制作一个可工作的JSFIDLE或类似工具来显示您的问题,以便其他人能够提供帮助。
//manipulacion 
var contLin=1
    $(document).ready(function () {
        $("#estado"+contLin).change(function () {      
            if ($("#estado"+contLin).val() == 2) {
                $("#sino"+contLin).show();
                $("#sexo"+contLin).hide();       
            }
            if ($("#estado"+contLin).val() == 3) {
                $("#sino"+contLin).hide();
                $("#sexo"+contLin).show();
            }
}           );



});


$(document).ready(function(){
    //evento que se dispara al hacer clic en el boton para agregar una nueva fila
    $(document).on('click','.clsAgregarFila',function(){
        //almacenamos en una variable todo el contenido de la nueva fila que deseamos
        //agregar. pueden incluirse id's, nombres y cualquier tag... sigue siendo html

        var strNueva_Fila='<tr>'+
'<td><select id="estado'+contLin+'"><option value="1">Seleccione 1 opcion</option><option value="2">Laboratorio</option><option value="3">Datos Generales</option></select></td>' +
'<td><select name="sino'+contLin+'" id="sino"style="display:none"><option value="1">Si </option><option value="2">No</option></select></td>'+
'<td> <select name="sexo'+contLin+'" id="sexo"  style="display:none"><option value="1">Masculino </option><option value="2">Femenino</option></select><td>'+
'<td><input type="button" value="+" class="clsAgregarFila"><input type="button" value="-" class="clsEliminarFila"></td>'+
'</tr>';

contLin++;

        var objTabla=$(this).parents().get(3);


        $(objTabla).find('tbody').append(strNueva_Fila);


        if(!$(objTabla).find('tbody').is(':visible')){

            $(objTabla).find('caption').click();
        }
    });


    $(document).on('click','.clsEliminarFila',function(){

        var objCuerpo=$(this).parents().get(2);
            if($(objCuerpo).find('tr').length==1){
                if(!confirm('Esta es el única fila de la lista ¿Desea eliminarla?')){
                    return;
                }
            }


        var objFila=$(this).parents().get(1);

            $(objFila).remove();
    });



});