Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an input element's value in jQuery

How can I get the value of an input element in jQuery?

like image 971
Rakesh Sabbani Avatar asked Sep 09 '10 05:09

Rakesh Sabbani


People also ask

How do I find the ID of a text box?

You can set a common class for your textbox inside grid and then using class you can get text box id and it's value. here i have just given an example. it's not in grid but it should work for gridview too.

How do I find the value of an anchor tag?

Answer: Use the jQuery . attr() Method attr() method to dynamically set or change the value of href attribute of a link or anchor tag. This method can also be used to get the value of any attribute.


2 Answers

If this is your textbox:

<input type="text" id="mytextBox" value="" />

You will be getting it's value using the textbox's ID=mytextBox...

var value = $("#mytextBox").val()

References

  • JQuery .val()
  • JQuery
like image 150
Garis M Suero Avatar answered Sep 24 '22 00:09

Garis M Suero


$("#elementId").val()
like image 27
Bozho Avatar answered Sep 21 '22 00:09

Bozho