2010-08-16 65 views
2

提交標籤我有HTML如下檢索使用jQuery

<div class="element-container" id="div_3"> 
    <div id="submit_submit" class="element"> 
     <div class="fleft"> 
      <input type="submit" value="Click me!" name="submit" id="submit"/> 
     </div> 
     <div class="clr"/> 
    </div> 
</div> 

,當我在元素容器單擊我想提交按鈕的標籤即點擊我!

請給一個解決方案,我試過$('#submit').attr('value')。但我沒有得到結果

+1

你不應該使用提交作爲名稱的表單元素,請參閱http://markushedlund.com/dev-tech/unable-to-javascript-submit-a-form-using-jquery以瞭解更多內容。 – Znarkus 2010-08-16 14:12:01

+0

非常感謝你:) – 2010-08-16 14:34:40

回答

2

jQuery中有一個內置的方法用於返回INPUT元素的值val()。下面應該工作:

$('#submit').val(); 

我從來沒有與一個提交按鈕嘗試過專門雖然。

+0

我認爲它沒有得到因爲id,名字有價值提交。這是一個保留字嗎? – 2010-08-16 13:43:53