Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:16:16+00:00 2026-06-17T13:16:16+00:00

I have a jQuery script that finds all the input type=radio in the html

  • 0

I have a jQuery script that finds all the input type=radio in the html and appends some fancy css on them. The problem is that I want some of the radio buttons to be untouched.
Here is the jQuery:

$(this).each(function (i) {
    if ($(this).is('[type=checkbox],[type=radio]')) {
        var input = $(this);
        var label = $('label[for=' + input.attr('id') + ']');
        var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio';
        $('<div class="custom-' + inputType + '"></div>').insertBefore(input).append(input, label);
        var allInputs = $('input[name=' + input.attr('name') + ']');
        label.hover(

        function () {
            $(this).addClass('hover');
            if (inputType == 'checkbox' && input.is(':checked')) {
                $(this).addClass('checkedHover');
            }
        },

        function () {
            $(this).removeClass('hover checkedHover');
        });
        input.bind('updateState', function () {
            if (input.is(':checked')) {
                if (input.is(':radio')) {
                    allInputs.each(function () {
                        $('label[for=' + $(this).attr('id') + ']').removeClass('checked');
                    });
                };
                label.addClass('checked');
            } else {
                label.removeClass('checked checkedHover checkedFocus');
            }
        })
            .trigger('updateState')
            .click(function () {
            $(this).trigger('updateState');
        })
            .focus(function () {
            label.addClass('focus');
            if (inputType == 'checkbox' && input.is(':checked')) {
                $(this).addClass('checkedFocus');
            }
        })
            .blur(function () {
            label.removeClass('focus checkedFocus');
        });
    }
});

This works fine but it will change all the radio buttons on the page. And I want to add some radio buttons that needs to be unchanged. I want radio buttons in this html code to be untouched by the script above:

<p class="field switch">
    <input type="radio" id="radioZ1" name="field1" checked />
    <input type="radio" id="radioZ2" name="field2" />
    <label for="radioZ1" class="cb-enable selected"><span>Enable</span>
    </label>
    <label for="radioZ2" class="cb-disable"><span>Disable</span>
    </label>
</p>

So I was trying to add .not() right after the .is() but I have had no luck. Can somebody help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:16:18+00:00Added an answer on June 17, 2026 at 1:16 pm

    Here is my working solution:

    if($(this).is('[type=checkbox],[type=radio]') && !($(this).is("p.switch > [type=radio]")) ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script on jquery that load some site in iframe using: $(#demo_frame).attr('src',
I have a custom jQuery script that works fine in all bowsers but one
I have this simple code: <html> <head> <script src=jquery-1.5.1.min.js type=text/javascript></script> <script type=text/javascript> $(function() {
I have a jQuery script that polls my server for new data, but it
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I have a simple jQuery script that I'm trying to build upon but I
I have a jQuery search script that uses tabs for the user to define
I have a JS/jQuery script that adds our leads (web contacts) to the DOM
I have a datalist being generated with ASP, but unfortunately the jQuery script that
I have a script that allows me to dynamically create lists via jQuery. I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.