What is prop() in JQuery?
The prop() method in JQuery is used to adjust the properties or attributes of an HTML element.
Syntax
$(selector).prop(property, value)
//for multiple values
$(selector).prop({property:value, property:value,...})
The figure below shows an example.
Parameters
The prop() requires the attribute you want to adjust the new value.
Example
<!DOCTYPE html><html><head><title>Jquery prop()</title><link href="style.css" rel="stylesheet" type="text/css" /><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><script>$(document).ready(function(){$("button").click(function(){$("button").prop("disabled", true);});});</script></head><body><button>Click me</button></body></html>
In the code above, the button changes the disabled property or attribute to true when the button itself is clicked.
Thank you for reading!