我正在尝试使用jQuery设置隐藏字段的值。
<input type="hidden" value="" name="testing" />
我正在使用此代码:
var test = $("input[name=testing]:hidden");
test.value = 'work!';
但是它不起作用。我的代码有什么问题?
我正在尝试使用jQuery设置隐藏字段的值。
<input type="hidden" value="" name="testing" />
我正在使用此代码:
var test = $("input[name=testing]:hidden");
test.value = 'work!';
但是它不起作用。我的代码有什么问题?
Answers:
$('input[name="testing"]').val(theValue);
input[name="testing"->在引号之间进行测试...每当设置某些值不起作用时,请尝试首先获取该元素。问题不是.val(),而是选择器