使用JQUery Next()API从隐藏的文本框中获取数据
我正在对JQuery进行一些自我学习,遇到了一个问题:使用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 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>