2012-05-28 26 views

回答

4

試試這個:

$('input[name="customergroupname"]').val(""); 
+0

+1男子!現在我需要鍵入15個字符! –

3

獲取和設置包裹在一個jQuery對象表單元素的值正在與使用jQuery做val功能:

$('input[name="customergroupname"]').val(""); 

.value只能用於DOM元素,如下:

$('input[name="customergroupname"]').eq(0).value =""; 

$(...)  // This is a jQuery object. 
$(...)[n] // This is a DOM object in the nth place in the set. 
$(...).eq(n) // This is a DOM object in the nth place in the set. 
+0

+1表示明確。 – thecodeparadox

+0

傍晚傍晚+1 –

-3

嘗試:

$('input[name="customergroupname"]').value=""; 

我在引號包裹customergroupname

非常真實,我混合了報價。現在編輯。

+0

現在更糟! :(你混合了引號,現在'customergroupname'是一個變量。 – gdoron

+0

恐怕還是錯的,請看看我的答案'.val' V.S.'.value' – gdoron

0

工作演示http://jsfiddle.net/vN74v/2/

代碼

$('#hullk').click(function(){ // in example when you click the button 
    $('input[name="customergroupname"]').val(""); 
}); 
​ 
0

DOM level 2 specifications,您可以訪問:

document.forms["foo"].elements["customergroupname"].value = ''; 

如果formNamefieldName是常數,而不是變量,你CA n使用文本語法:

document.forms.foo.elements.customergroupname.value = ''; 
相關問題