HOW DO YOU SELECT AN ITEM USING CSS CLASS OR ID AND GET THE VALUE BY USE OF JQUERY

Awadhendra Tiwari

Total Post:510

Points:2550
Posted by  Awadhendra Tiwari
JQuery 
 1578  View(s)
Ratings:
Rate this:
  1. Awadhendra Tiwari

    Post:510

    Points:2550
    How do you select an item using css class or ID and get the value by use of jquery

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!