2010-04-28 82 views

回答

9
$('#textbox').attr('title') 
$('#textbox').attr('name') 
0
var theTextBox = $('textarea'); 
var itsTitle = theTextBox.attr('title'); 
var itsName = theTextBox.attr('name'); 

也許你應該做一些更多的教程:|

+0

是的,謝謝,將來會做... – manraj82 2010-04-28 15:06:24

+4

textbox是不是一個有效的標籤,你的意思是'textarea'我想 – Zlatev 2010-04-28 15:06:28

+0

@Zlatev:我確實......只輸入了幾百萬次:P – Matt 2010-04-28 15:06:56

1

var attributeText = $("#textboxID").attr("attributeYouWantToRetrieve");

只需更換標題和名稱attributeYouWantToRetrieve

4

文本框,就像一個輸入元素?不同的地方是在文檔中,你的選擇可能會有所不同,但我會假設你已經給了它一個ID,因此HTML會是這個樣子:

<input type="text" title="tehTitle" name="tehName" id="textBox" /> 

因爲jQuery選擇使用我們的CSS語法可以target by id attribute

$("input#textBox") // more to come... 

然後,您可以使用jQuery的attr function閱讀它的標題和名稱屬性。

var title = $("input#textBox").attr("title"); 
var name = $("input#textBox").attr("name"); 
相關問題