2 Replies - 628 Views - Last Post: 19 August 2011 - 10:56 PM

#1 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

OnClick Issue.

Posted 19 August 2011 - 12:51 PM

Howdy,
I'm having a strange error that a if statement isn't working.
	 $("input[name*='default']").click(function() { 
		if($(this).val() != "Custom"){
			$(".crawlers").hide();
			$(".special").hide();
		} else {
			$(".crawlers").show();
			$(".special").show();
		}
	}); 
	



And my html:

<input type="radio" name="default" value="Allow" checked>
<input type="radio" name="default" value="Refuse">
<input type="radio" name="default" value="Custom">



Basically, .crawlers and .special (set by id and name) aren't hiding or showing when the radio buttons are clicked. The value is definitely changing, I added and alert on $(this).val() and it showed me the alert as Custom, Allow or Refuse.

Any idea what's going on?

Is This A Good Question/Topic? 0
  • +

Replies To: OnClick Issue.

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5612
  • View blog
  • Posts: 14,686
  • Joined: 18-April 07

Re: OnClick Issue.

Posted 19 August 2011 - 01:17 PM

But you have said look for elements with their "CLASS" set as crawlers and special... in other words elements like...

<div class="crawlers">something crawly</div>
<div class="special">something special</div>



If you want to specify by ID then you need...

$("#crawlers").hide();
$("#special").hide();



By using the period in the front of the name you are telling jQuery to look for elements with the matching class name... not ID or NAME.

:)

This post has been edited by Martyr2: 19 August 2011 - 01:17 PM

Was This Post Helpful? 1
  • +
  • -

#3 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: OnClick Issue.

Posted 19 August 2011 - 10:56 PM

Ha! I knew it was a simple issue, 30 minutes I was staring at this!

Thankyou :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1