简体   繁体   English

jQuery将无法在多级依赖?

[英]jquery won't work in multi level dependency?

$(document).ready(function() { 

     $("#ddlprod").change(function() {

        var pk= $("#ddlprod").val();

        $.ajax({

        url: "ajaxprintdropdown.php",

        type: "POST",

        data: 'pk='+pk,

        timeout: 5000,

        success:  function(output) {                            

            $('#divtesting').show();    //works well            
            $('#divtesting').html(output);   //works well
        },


        }); 


     $("#ddltesting").change(function(){
        alert('a');    //not functioning at all
        var c= $("#ddltesting").val();
        alert(c);   //not functioning at all    
      });



     });

ajaxprintdropdown.php's output ajaxprintdropdown.php的输出

<select name=ddltesting id=ddltesting >
<option value=''>--Select--</option>
<option value='test1'>bla for test1</option>
<option value='test2'>bla for test2</option>
</select>

Jquery not working for multi level dependency? jQuery不适用于多级依赖吗? $("#ddltesting").change(function(){ no response at all $("#ddltesting").change(function(){完全没有响应

Edit 编辑

@altCognito pointed out that live works with change events also. @altCognito指出,现场直播也适用于变更事件。 Then you can write 那你可以写

$("#ddltesting").live("change",function(){
    alert('a');    
    var c= $("#ddltesting").val();
    alert(c);   
});

From jQuery 1.4 Released jQuery 1.4发布

The change and submit events work reliably across browsers for both normal and live events. 更改和提交事件可在浏览器中正常运行和实时运行。 We override the normal change and submit events in Internet Explorer and replace them with events that work identically to the other browsers. 我们将覆盖常规更改并在Internet Explorer中提交事件,然后将其替换为与其他浏览器相同的事件。

Try 尝试

$("#sampletextbox").val(c);

instead of 代替

$("#sampletextbox").text(c);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM