使用jquery设置隐藏输入的值 [英] Set value of hidden input with jquery
本文介绍了使用jquery设置隐藏输入的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jQuery设置隐藏字段的值。
I'm trying to set the value of the hidden field below using jQuery.
<input type="hidden" value="" name="testing" />
我正在使用此代码:
var test = $("input[name=testing]:hidden");
test.value = 'work!';
但它不起作用。我的代码出了什么问题?
But its not working. What's wrong with my code?
推荐答案
您应该使用 val
而不是 value
。
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('input[name="testing"]').val('Work!');
});
</script>
这篇关于使用jquery设置隐藏输入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文