Methods to set jquery elements that cannot be used: Use the [.prop()] method to adjust the properties of the element. After setting the button to disabled, the button will turn gray and cannot be clicked. The code is [$(" button").prop("disabled", true);].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.
Methods that cannot be used to set jquery elements:
We can use jQuery to change non-CSS attributes of HTML elements. 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>
Related free learning recommendations: javascript( video)
The above is the detailed content of How to set jquery elements to be unusable. For more information, please follow other related articles on the PHP Chinese website!