Open In App
Related Articles

jQuery prop() Method

Improve Article
Save Article
Like Article

The prop() is an inbuilt method in jQuery that is used to set or return properties and values for the selected elements. When this method is used to return the property value, it returns the value of the FIRST matched element and when this method is used to set property values, it sets one or more properties for the selected elements.

Syntax :

$(selector).prop(para1, para2)

Parameters: It accepts two parameters which are specified below-

  • para1: It specifies the property.
  • para2: It specifies the value of the property in case of set.
  • Return Value:It returns the property and value set for the property for the selected element.
    jQuery code to show the working of prop() method:
  • html

    <!DOCTYPE html>
        <script src=
        <!-- jQuery code to show the working of this method -->
            $(document).ready(function () {
                $("button").click(function () {
                    var $x = $("p");
                    $x.prop("color", "green");
                    $x.append(" Property is color and its value: "
                        + $x.prop("color"));
            div {
                width: 250px;
                padding: 10px;
                height: 100px;
                border: 2px solid green;
            <!-- click on button this method -->
            <button>Click Here!</button>



    Last Updated : 13 Jul, 2023
    Like Article
    Save Article
    Similar Reads
    Related Tutorials