The implementation method of jquery to uncheck the select: first open the corresponding code file; then set the disabled attribute to disabled through the "attr()" method; finally run the code to see the effect of the select drop-down box being unchecked.
The operating environment of this tutorial: Windows 7 system, jquery3.3.1 version. This method is suitable for all brands of computers.
Related recommendations: "jquery video tutorial"
jquery makes select unselected:
In jquery, set select The drop-down box is not selectable and unchecked, mainly by setting the disabled attribute to disabled through the attr() method.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style> select{ /*为了看到效果这里添加了宽和高*/ width:100%; height:100px; margin:100px 0; } </style> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> </head> <body> <div id="div1"> <select id="select1"> <option value="1">我是第一个option</option> <option value="2">我是第二个option</option> <option value="3">我是第三个option</option> <option value="4">我是第四个option</option> </select> </div> <div id="select2"> <select> <option value="1">我是第一个option</option> <option value="2">我是第二个option</option> <option value="3">我是第三个option</option> <option value="4">我是第四个option</option> </select> </div> <script> $(function(){ $("select").each(function () { $(this).attr("disabled","disabled"); }); }); </script> </body> </html>
Rendering:
Instructions:
In this way, add disabled="disabled" directly to the select tag through the attr() method Property to disable select so that the select tag cannot be expanded and therefore cannot be selected.
The above is the detailed content of How to make the select unselected in jquery. For more information, please follow other related articles on the PHP Chinese website!