


Detailed explanation of jQuery setting radio button radio selection and deselection examples
This article mainly introduces the relevant information of jQuerySettingsRadio buttonradio selected/unavailable example code. It is very good and has reference value. Friends who need it can Please refer to the following
Because this part is "Daily Use of jQuery", it is based on specific needs and summarizes the knowledge points that need to be used. The code may not be well written, as long as it achieves the goal. So let’s first take a look at the requirements this time: the color block mode is based on the color mode, that is, the color block can be turned on when the color is turned on. The color block is not available when the color is turned off. The color block radio is available when the color is turned on. When the color is turned off, if the color block If the block is on, you need to turn it off, and that's about it.
Let's take a look at the demonstration effect first:
Let's take a look at jQuery's operation of the radio button radio.
1. The color block is not available when the color is turned off.
requires two steps. When the page is opened, detect if the color is turned off. Make the "on" of the color block unavailable:
if($("#coloroff[checked]")) { //alert("Hello Nowamagic!"); $("#blockon").attr("disabled", true); }
In addition, when the color switch is switched, that is, when switching from on to off, make the color block on unavailable, and select the color block off at the same time:
$("#coloroff").change(function(){ $("#blockon").attr("disabled", true); $("#blockoff").attr("checked",true); })
2. Make the color block available when the color is switched from off, this is simple:
$("#coloron").change(function(){ $("#blockon").attr("disabled", false); })
The full code is:
$(document).ready(function(){ if($("#coloroff[checked]")) { //alert("Hello Nowamagic!"); $("#blockon").attr("disabled", true); } $("#coloroff").change(function(){ $("#blockon").attr("disabled", true); $("#blockoff").attr("checked",true); }) $("#coloron").change(function(){ $("#blockon").attr("disabled", false); }) });
Add a few knowledge points:
checkbox, radio These controls have no readonlyattribute, so you need to use disabled Properties to toggle their "available/unavailable" status.
To set the radio to be unavailable, you can use the attr() method, that is, attr("disabled", true).
Setting the selected status of radio also uses the attr() method, attr("checked",true).
The above is the detailed content of Detailed explanation of jQuery setting radio button radio selection and deselection examples. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

There could be several reasons why your Windows laptop won't boot. Memory failure, dead battery, faulty power button, or hardware issues are all common causes. Here are some solutions to help you resolve this issue. Laptop won't turn on after pressing the power button If your Windows laptop still won't turn on after pressing the power button, here are some steps you can take to resolve the issue: Is your laptop fully charged? Perform a hard reset to clean your laptop Reseat the memory Transparent CMOS type battery Take your laptop for repair. 1] Is your laptop fully charged? The first thing to do is to check if your laptop is fully charged. Laptop won't start if battery is drained

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

After the release of the iPhone 15 series, there have been constant revelations about the appearance and configuration of Apple’s new iPhone 16. What does iPhone 16 look like? Is there any improvement in iPhone 16? Recently, an overseas blogger showed off the design of the iPhone 16 series. The overall design is basically the same as the iPhone 15 series. As you can see from the picture, the entire iPhone 16 series is equipped with a new "shoot" button as standard, allowing users to take photos more conveniently. In addition, other design details are still unknown. The message shows that this new button will be used to shoot videos and is located below the power button. Previous news has mentioned that it may be a capacitive solid-state button, but recent reports indicate that it should still be a

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

NASA has confirmed the existence of a global electric field around Earth, achieved through a recent rocket launch. This is a big deal, since this is the first direct measurement of a phenomenon which has been long theorized but has never been observe
