例如:
<script>
$(document).ready( function() {
alert( $(this).getBelowElementToThisScript('form').id );
});
</script>
<form id="IamTheNext"></form>
<form id="Iamnot"></form>
此代码应显示此消息:IamTheNext
此外,该解决方案还需要与此示例配合使用:
<script src="getbelowelement.js"></script>
<form id="IamTheNext"></form>
<form id="Iamnot"></form>
谢谢
最佳答案
试试这个:
var form = $('script[src="getbelowelement.js"]').next();
但我建议使用表单 ID:
var form = $('#IamTheNext');
关于javascript - 在 jQuery 中获取就绪函数代码下方的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6798509/