這個工作在jQuery的1.3.2,而不是在1.4選擇在jQuery的1.4選擇字段不工作
$("#container").children().map(function() {
var child = $(this);
if (child.is(":select")) {
//do something with child
}
});
什麼是jQuery的1.4這樣做的正確方法?
這個工作在jQuery的1.3.2,而不是在1.4選擇在jQuery的1.4選擇字段不工作
$("#container").children().map(function() {
var child = $(this);
if (child.is(":select")) {
//do something with child
}
});
什麼是jQuery的1.4這樣做的正確方法?
如果你想選擇的元素:
$("#container").children().map(function() {
var child = $(this);
if (child.is("select")) {
//do something with child
}
});
兒童()不接受一個選擇,所以你可以減少到:
$("#container").children('select').map(function() {
var child = $(this);
//do something with child
});
謝謝,還是不敢相信:是大不了的:) – Vnuk 2010-03-31 12:38:42
如果我理解正確的話,我會建議訪問tagName
(測試):
$("#container").children().map(function() {
var child = $(this);
if (child[0].tagName == "SELECT") { // or this.tagName == "SELECT"
//do something with child
}
});
你使用的是jQuery 1.4.2嗎? – 2010-03-31 12:21:45
是的,它在1.4.2中不起作用 – Vnuk 2010-03-31 12:37:02