www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to color a label when passing value "0"

Hybrid View

  1. #1
    Join Date
    Jul 2014
    Posts
    12

    how to color a label when passing value "0"

    Hi,

    i use this code to disable radio button when passing value is "0"
    HTML Code:
    $('input[type="radio"]').prop('disabled', function() {
       return $(this).next().text().match(/\((\d+)\)/)[1] == 0;
      
    
    });
    when this value is "0" also i want to color that label

    HTML Code:
    <form id="form1" name="form1" method="post" action="">
      
      <label >
      <input type="radio" name="radio" id="rd" value="" />
      </label> 
      confirm
    </form>
    please help me

  2. #2
    Join Date
    May 2014
    Posts
    905
    That jquery garbage really proves how needlessly and pointlessly cryptic jQuery is... and remember, that's coming from someone who can hand assemble machine language for four different processor families. I'd punch myself in the face before deploying code that looked like that. When you disable the input you need to hook it's parentNode, but with jQ's garbage daisy-chaining of methods, good luck fitting it in there.

    I can't even figure out what that's supposed to be doing. You've got an empty value... you're pulling text on something that has no text, then trying to match decimal pattern to zero?!?

    Much less that markup doesn't make any sense either -- what is "confirm"? Is that the ACTUAL label for the input, and if so why isn't it inside the label? Not sure what you expect "next()" to be either since there is no nextSibling to the input.

    Can you better explain what you are trying to accomplish here? I get the feeling the incomplete snippet and broken markup aren't telling us enough about what it is you're actually trying to do.

    Maybe with a better explanation we could get you something cleaner and more comprehendable than that jQuery mess.

    In case you couldn't tell, not a fan. 99% of what people do with jQuery falls into three categories -- things that would be cleaner/simpler without it, CSS' job, or has no blasted business on websites in the first place!
    Java is to JavaScript as Ham is to Hamburger.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles