how do i retrieve a textbox's title and name using jquery?
A:
var theTextBox = $('textarea');
var itsTitle = theTextBox.attr('title');
var itsName = theTextBox.attr('name');
Maybe you should do some more tutorials :|
Matt
2010-04-28 15:03:58
yeah thanks,will do in future...
manraj82
2010-04-28 15:06:24
textbox is not a valid tag, you mean `textarea` i suppose
Zlatev
2010-04-28 15:06:28
@Zlatev: I did indeed... only typed it a few million times before :P
Matt
2010-04-28 15:06:56
+1
A:
var attributeText = $("#textboxID").attr("attributeYouWantToRetrieve");
just replace title and name for attributeYouWantToRetrieve
eppdog
2010-04-28 15:05:15
+4
A:
Textbox, like an input element? Depending on where it is in the document, your selector may vary, but I'll assume you've given it an id, so the HTML would look something like this:
<input type="text" title="tehTitle" name="tehName" id="textBox" />
Since jQuery selectors use CSS syntax we can target by id attribute:
$("input#textBox") // more to come...
You can then use the jQuery attr function to read it's title and name attribute.
var title = $("input#textBox").attr("title");
var name = $("input#textBox").attr("name");
LeguRi
2010-04-28 15:06:52