它适用于 jquery 1.3,但是当我尝试用 1.8 替换它时,我得到“不支持的伪:全部”错误:
这是我当前的代码:
$(function () {
$('input[id$=btnAdd]').click(function (e) {
e.preventDefault();
// Assuming you get a JSON object from a service
var lenBefore = $('select[id$=DDL] :all').length;
var obj = { "6": "Item6", "7": "Item7", "8": "Item8" };
$.each(obj, function (value, text) {
$('select[id$=DDL]').append($('<option></option>').val(value).html(text))
});
var lenAfter = $('select[id$=DDL] :all').length;
$("#para").html("<b>" + (lenAfter - lenBefore) + "</b>" + " new items were added");
$(this).attr("disabled", "disabled");
});
});
您的回答会很有帮助。
最佳答案
我想你想要 $('select[id$=DDL] option')
或 $('select[id$=DDL] *')
或 $('select[id$=DDL]').children()
关于javascript - 如何修复 jQuery 1.8 “unsupported pseudo: all” 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13246670/