Home > Article > Web Front-end > How to set the jquery element to be unavailable
How to set the jquery element to be unavailable: first create a js sample file; then use jQuery to change the non-CSS attributes of the HTML element; finally pass "$("button").prop("disabled", true );" Just disable all buttons.
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, thinkpad t480 computer.
Recommended: "jquery video tutorial"
Using jQuery to set elements is not available
We can use jQuery to change HTML elements non-CSS properties. For example, you can disable buttons.
When you set the button to disabled, the button will turn gray and cannot be clicked.
jQuery has a .prop() method that allows you to adjust the properties of elements.
The following code shows how to disable all buttons:
$("button").prop("disabled", true);
Example: Let the target1 button be disabled
<script> $(document).ready(function() { $("#target1").css("color", "red"); $("#target1").prop("disabled", true); }); </script> <!-- Only change code above this line. --> <div class="container-fluid"> <h3 class="text-primary text-center">jQuery Playground</h3> <div class="row"> <div class="col-xs-6"> <h4>#left-well</h4> <div class="well" id="left-well"> <button class="btn btn-default target" id="target1">#target1</button> <button class="btn btn-default target" id="target2">#target2</button> <button class="btn btn-default target" id="target3">#target3</button> </div> </div> <div class="col-xs-6"> <h4>#right-well</h4> <div class="well" id="right-well"> <button class="btn btn-default target" id="target4">#target4</button> <button class="btn btn-default target" id="target5">#target5</button> <button class="btn btn-default target" id="target6">#target6</button> </div> </div> </div> </div>
Rendering:
The above is the detailed content of How to set the jquery element to be unavailable. For more information, please follow other related articles on the PHP Chinese website!