What is the use of #id selector in JQuery library.

December 28, 2009 | Filed Under PHP | Comments Off

ID attribute play very important rule in web page.
In a web page every web element must have unique id.

Ex-<input type=”text” name=”text1” id=”text1”/>
<input type=”text” name=”text2” id=”text2”/>

To  get value of above  textbox from #id selector using jquery need to write below code.

var value=$(“# text1”).val();

another example, To apply css on #myDivId element use below code.

$(“#myDivId”).css(“border”,”3px solid red”);

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker