How to make the select unselected in jquery
Dec 22, 2020 am 10:37 AMThe 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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

In-depth analysis: jQuery's advantages and disadvantages

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute?
