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"); 
相关问题