Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JQUery Next()API从隐藏的文本框中获取数据_Jquery - Fatal编程技术网

使用JQUery Next()API从隐藏的文本框中获取数据

使用JQUery Next()API从隐藏的文本框中获取数据,jquery,Jquery,我正在对JQuery进行一些自我学习,遇到了一个问题: 我正试图使用JQuery next()API从隐藏类型的文本框字段中获取数据,但未能做到这一点。 这是我的密码: $(document).ready(function(){ $(".Testing").click(function(){ var what = $(this).next().val(); alert(what); }); }); <span class="Testing">H

我正在对JQuery进行一些自我学习,遇到了一个问题:
我正试图使用JQuery next()API从隐藏类型的文本框字段中获取数据,但未能做到这一点。
这是我的密码:

 $(document).ready(function(){
    $(".Testing").click(function(){
    var what =  $(this).next().val();
    alert(what);
    });
 });

<span class="Testing">Hello</span><br/>
<input type="hidden" value="World">

 <span class="Testing">Hi</span><br/>
 <input type="hidden" value="There">
$(文档).ready(函数(){
$(“.Testing”)。单击(函数(){
var what=$(this.next().val();
警惕(什么);
});
});
你好

你能帮我解决这个问题吗

参考链接:

.next()用于包含一组dom对象的jquery对象

你可以用它来做列表之类的事情。查看文档:


事实上,你应该能够做你想做的事。忽略此操作。

您可能忘记关闭对$(文档)的调用。准备好了。 它需要额外的})


$(文档).ready(函数(){
$(“.Testing”)。单击(函数(){
var what=$(this.next().val();
警惕(什么);
});
});
你好
你好
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"  type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(".Testing").click(function(){
        var what =  $(this).next().val();
        alert(what);
    });
});
</script>
</head>
<body>

<span class="Testing">Hello</span>
<input type="hidden" value="World">

<span class="Testing">Hi</span>
<input type="hidden" value="There">

</body>
</html>