$(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 的输出
<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 不适用于多级依赖?
$("#ddltesting").change(function(){
完全没有响应
最佳答案
编辑
@altCognito 指出实时也适用于变更事件。然后就可以写了
$("#ddltesting").live("change",function(){
alert('a');
var c= $("#ddltesting").val();
alert(c);
});
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.
尝试
$("#sampletextbox").val(c);
而不是
$("#sampletextbox").text(c);
关于javascript - jquery 无法在多级依赖中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2083873/