Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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 bind不´;不能为多个选择器工作_Javascript_Jquery_Html_Dom - Fatal编程技术网

Javascript bind不´;不能为多个选择器工作

Javascript bind不´;不能为多个选择器工作,javascript,jquery,html,dom,Javascript,Jquery,Html,Dom,我有这样的jQuery: jqObj.bind('change', function () { debugger; }); jqObj匹配两个元素(dropDownList),但只有第一个元素响应“更改”事件,第二个元素在位置[1]上对更改不做任何操作 这是我的HTML: <div id="area-146"> <div class="blockContent"> <div class="form-element dup

我有这样的jQuery:

jqObj.bind('change', function () {
      debugger;
    });
jqObj匹配两个元素(dropDownList),但只有第一个元素响应“更改”事件,第二个元素在位置[1]上对更改不做任何操作

这是我的HTML:

<div id="area-146">
    <div class="blockContent">
        <div class="form-element duplicate ">
            <label for="71">Idioma </label>
            <select id="combo-71" style="width: 200px;">
                <option value="Russo">Russo</option>
                <option value="Sueco">Sueco</option>
            </select>
            <input id="text-71" value="Escolhe uma opção" style="margin-left: -203px; width: 180px; height: 1.2em; border: 0;">
            <br style="clear: left;">
        </div>     
        <div class="form-element duplicate ">
            <label for="72">Escrita </label>
            <input class="peq" id="72" maxlength="35" name="Input.Fields[72]" size="35" title="" type="text" value="">   
            <br style="clear: left;">
        </div>     
        <div class="form-element duplicate ">
            <label for="73">Conversação </label>
            <input class="peq" id="73" maxlength="35" name="Input.Fields[73]" size="35" title="" type="text" value=""> 
            <br style="clear: left;">
        </div>     
        <div class="form-element duplicate ">
            <label for="85"> </label>
            <br>
            <br style="clear: left;">
        </div>     
    </div>
    <div id="area-146-2"><div class="form-element duplicate ">
        <label for="71">Idioma </label>
        <select id="combo-71-2" style="width: 200px;">
            <option value="Russo">Russo</option>
            <option value="Sueco">Sueco</option>
        </select>
        <input id="text-71-2" value="Escolhe uma opção" style="margin-left: -203px; width: 180px; height: 1.2em; border: 0;">
        <br style="clear: left;">
    </div>
    <div class="form-element duplicate ">
        <label for="72">Escrita </label>
        <input class="peq" id="72-2" maxlength="35" name="Input.Fields[72]" size="35" title="" type="text" value="">
        <br style="clear: left;">
    </div>
    <div class="form-element duplicate ">
        <label for="73">Conversação </label>
        <input class="peq" id="73-2" maxlength="35" name="Input.Fields[73]" size="35" title="" type="text" value="">
        <br style="clear: left;">
    </div>
    <div class="form-element duplicate ">
        <label for="85"> </label>
        <br>
        <br style="clear: left;">
    </div>
</div>

习语
鲁索
苏伊科

埃斯克里塔
Conversação


习语 鲁索 苏伊科
埃斯克里塔
Conversação


jqObj对象如下所示:

[<select id=​"combo-71" style=​"width:​ 200px;​">​…​</select>​, <select id=​"combo-71-2" style=​"width:​ 200px;​">​…​</select>​]
[​…​​, ​…​​]
我不知道为什么它只响应第一个元素,而不响应两个元素。 元素是动态添加的,然后我进行新的选择以匹配页面中的所有现有元素。我也不能使用.on(),因为我的jQuery版本是1.6


有什么建议吗?

bind
不会将侦听器绑定到调用
bind
后动态创建的元素。但是,
delegate
会,您只需要指定适当的祖先:

$('#area-146').delegate('select', 'change', function(){
    //glorious code!
});
ref:

在这里可以正常工作
$()。委托(,)