---
title: "why are use the prop method in jquery? explain with example."  
description: "why are use the prop method in jquery? explain with example."  
author: "Ethan Karla"  
published: 2021-07-28  
canonical: https://answers.mindstick.com/qa/93813/why-are-use-the-prop-method-in-jquery-explain-with-example  
category: "web application"  
tags: ["web development", "web application development"]  
reading_time: 2 minutes  

---

# why are use the prop method in jquery? explain with example.

why are use the prop [method in jquery](https://www.mindstick.com/forum/156670/has-method-in-jquery)? [explain](https://yourviews.mindstick.com/view/86025/content-created-for-humans-not-for-bots-explain-this-statement) with example.

## Answers

### Answer by Ravi Vishwakarma

The prop () [method](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) in jQuery is used to get and set the property of an selected element. Such as width, height, color etc. Syntax:

```
$(selector).prop (property-name)
 This signature are used to get the property
$(selector).prop (property-name, value)
 And this signature are used for setting the property of selected elements
$(selector).prop (property-name, function (index, currentvalue))
 Also this signature set property and this function action at the end of prop ()
$(selector).prop ({property: value, property: value, ...})
 Also this signature set the multiple properties
```

Example

```
<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <script src='https://code.jquery.com/jquery-1.10.2.js'></script>
<script>
    $(document).ready(function () {
        $('button').click(function () {
            $('img').prop({ width: 300 });
            $('p').text('set image property ( width : 300px )');
        });
    });
</script>
</head>
<body>
<img src='https://source.unsplash.com/1600x900/?tree,water' width='500px' ><br>
    <p>default image property ( width : 500px )</p>
<button>Set the width property of the image</button>
</body>
</html>  
```

Output :

![why are use the prop method in jquery? explain with example.](https://answers.mindstick.com/questionanswer/cbbf1d0b-d1ce-42bf-97b4-973d9c4d6929/images/a24544f2-4977-407f-9511-e560a8a61b79.png)

\


---

Original Source: https://answers.mindstick.com/qa/93813/why-are-use-the-prop-method-in-jquery-explain-with-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
