gpt4 book ai didi

javascript - 为什么 .next() 给我 'undefined'

转载 作者:行者123 更新时间:2023-12-01 02:24:40 24 4
gpt4 key购买 nike

为什么 .next() 返回“未定义”? 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 对象没有 checked 属性。

您可以...

(a) 使用 [0]get(0) 对原生 DOM 元素添加下标。

(b) 访问 prop('checked')(>= 仅限 jQuery 1.6。)

(c) 使用 is(':checked')

关于javascript - 为什么 .next() 给我 'undefined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6184090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com