Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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
Jquery 检查textarea的元素类型,选择一个,按钮不工作_Jquery_Vbscript - Fatal编程技术网

Jquery 检查textarea的元素类型,选择一个,按钮不工作

Jquery 检查textarea的元素类型,选择一个,按钮不工作,jquery,vbscript,Jquery,Vbscript,我正在将vb脚本函数转换为javascript 如果oElement.type=“text”或oElement.type=“textarea”或oElement.type=“checkbox”或oElement.type=“选择一个”或oElement.type=“按钮”,则 我需要转换vbscript行。当我使用以下解决方案时,它会为“textarea”、“select-one”和“button”提供一些脚本错误。这对“text”和“checkbox”很好 $("#frmOrder").c

我正在将vb脚本函数转换为javascript

如果oElement.type=“text”或oElement.type=“textarea”或oElement.type=“checkbox”或oElement.type=“选择一个”或oElement.type=“按钮”,则

我需要转换vbscript行。当我使用以下解决方案时,它会为“textarea”、“select-one”和“button”提供一些脚本错误。这对“text”和“checkbox”很好

  $("#frmOrder").children().each(function () {
    var child = $(this);
    // type checking for textarea,select-one,button is not working.
    if (child.is(":text") || child.is(":checkbox")) {
        if(Number(child.attr('tabindex')) >= nIndex) {
            child.attr('tabindex', child.attr('tabindex')+ <%=nChemIndexIncrement%>);
        }
    }
});
$(“#frmOrder”).children().each(函数(){
var child=$(这个);
//键入文本区域检查,选择一个,按钮不工作。
if(child.is(“:text”)| | child.is(“:复选框”)){
if(Number(child.attr('tabindex'))>=nIndex){
child.attr('tabindex',child.attr('tabindex')+);
}
}
});

有人能帮我解决这个问题吗?

您必须检查有效的css选择器,
:hover
first child
就是这些伪类的示例<代码>:复选框和文本不存在。请尝试输入[type=text]

$("#frmOrder").children().each(function () {
    var child = $(this);
console.log(child);
    // type checking for textarea,select-one,button is not working.
    if (child.is("input[type=text]") || child.is("input[type=checkbox]") || child.is("textarea") || child.is("button") || child.is("input[type=button]")) {
        if(Number(child.attr('tabindex')) >= nIndex) {
            child.attr('tabindex', child.attr('tabindex')+ nChemIndexIncrement);
        }
    }
});

请参阅此工作JSFIDLE:

未测试,但
child.is('[type=checkbox]')
etc应该可以工作是。它适用于复选框和文本。但不适用于“textarea”、“select-one”和“button”,这段代码运行良好。当我逐个选中“文本区域”、“选择一个”和“按钮”时。它给出了错误。但是对于文本和复选框来说效果很好。显示代码时最好使用jsfiddle.net。“不工作”是没有帮助的。这是一个巨大的功能,LOC为200行。和超过17000行的页面。其他不依赖于此单元。我是否可以添加
子项(“选择一个”)
也可以?我不知道名称为
select one
的HTML元素。也许这个问题很有帮助:为什么你们要检查按钮两次?为了演示。因为你拒绝发布代码,所以我不得不编造一些东西。我可以用select来处理这个,
child.is(“input[type=select]”