为什么.next()给我'undefined' [英] why does .next() give me 'undefined'
本文介绍了为什么.next()给我'undefined'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么.next()会返回'undefined'? http://jsfiddle.net/radek/sD6JB/2/
why does .next() returns 'undefined'? http://jsfiddle.net/radek/sD6JB/2/
html
<button value="login|basic" class="square_button button_background" type="button"> run </button>
<input name="restore" title="restore before ant run" type="checkbox">
<button value="test|advanced" class="square_button button_background" type="button"> run </button>
<input name="restore" title="restore before ant run" type="checkbox">
<button value="best|4444" class="square_button button_background" type="button"> run </button>
<input name="restore" title="restore before ant run" type="checkbox">
<div id='results'/>
javascript + jQuery
$(document).ready(function(){
$('button[type=button]').click(function(){
var params = $(this).val();
document.getElementById("results").innerHTML+=
"<BR>"+params.split('|')[0]+" - "
+ params.split('|')[1]+" - "
+ $(this).next().checked;
});
});
推荐答案
jQuery对象没有选中
属性。
A jQuery object has no checked
property.
你可以......
(a)使用 [0]
或 get(0)
。
(b)访问 prop('checked')
(> =仅限jQuery 1.6。)
(b) Access prop('checked')
(>= jQuery 1.6 only.)
(c)使用是(':已检查')
。
这篇关于为什么.next()给我'undefined'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文