Jump to content


Photo

Code I have incorrect...


Best Answer requinix, 14 May 2014 - 12:37 PM

Tons of them: don't use smart quotes.

$(function() {

$("[name='pet_type']").change(function() {

    $("[name='breed']").removeAttr("disabled");

    $("[name='breed']").children("data-pet-type[name!='" + $(this).val() + "']").hide();

    $("[name='breed']").children("data-pet-type[name='" + $(this).val() + "']").show();

});

});
Go to the full post


  • Please log in to reply
2 replies to this topic

#1 jpopuk

jpopuk

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 14 May 2014 - 09:30 AM

I have a small bit of jquery code that is not working:

$(function() {

$(‘’[name=\'pet_type\']”).change(function() {

    $(‘’[name=\'breed\']”).removeAttr(‘disabled’);

    $(‘’[name=\'breed\']”).children(‘data-pet-type[name!=\'’ + $(this).val() + ‘\']’).hide();

    $(‘’[name=\'breed\']”).children(‘data-pet-type[name=\'’ + $(this).val() + ‘\']’).show();

});

});

My javascript is not good at all, so cannot spot errors?

 

Any help would be much appreciated! :)

 

Thanks



#2 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,315 posts
  • LocationWA

Posted 14 May 2014 - 12:37 PM   Best Answer

Tons of them: don't use smart quotes.
$(function() {

$("[name='pet_type']").change(function() {

    $("[name='breed']").removeAttr("disabled");

    $("[name='breed']").children("data-pet-type[name!='" + $(this).val() + "']").hide();

    $("[name='breed']").children("data-pet-type[name='" + $(this).val() + "']").show();

});

});


#3 jpopuk

jpopuk

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 14 May 2014 - 02:30 PM

Thank you :)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com