Home > DeveloperSection > Interviews > How do you select an item using css class or ID and get the value by use of jquery

Posted on    May-20-2011 2:54 AM

 JQuery JQuery 
 1 Answer(s)
  1360  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Posted on    May-20-2011 12:00 AM

If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code

$('#MyId') for ID and for classs $('.MyClass') and for value

var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item

$('#MyId').val("print me"); // set the value of a form input

Don't want to miss updates? Please click the below button!

Follow MindStick