Jquery find class and get the value

I am going to share how to find class and get the value. Jquery provide very easy to way find class and get value. You can find any value of html attribute using Jquery like class, id, tag etc. You can use find() method search all descendant elements of the selected element.

Now i am give you some example to better way to understand.

Example

In this example you can get value of input box from calss.

HTML element

<div id="element">
    <p>
        <input type="text" class="yourClass" value="my value" name="yourtext"/>
    </p>
</div>

Jquery Code

var yourVar = $("#element").find('.yourClass').val();
alert(yourVar);
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments