Friday, June 18, 2010

jQuery equivalent for document.getElementById("") in javascript

Hi,


When i am trying to write the client validation i used document.getElementById("") to get the value of the control and then validate that and return the result. So, when i move on to jQuery i try to figured out what would be the equivalent code for that i tried


var _Text = $("#controlid").value; //to get the content


but i didn't get the content. So after i browsed in the google and found the $("") ,selector, in jQuery the array so we need to use the array bracket or get method to get the content of the control.


var _Text = $("#controlid")[0].value
or
var _Text = $("#controlid").get(0).value

No comments:

Post a Comment