Andrew Charlton Andrew Charlton - 4 days ago 5
jQuery Question

Using jquery to hide and show tables with option values

I've been using this bit of jquery code on my website:

jQuery(document).ready(function() {
$('#tablets').change(function() {
$('#LeapPad 2 Explorer,#VTech InnoTab 2').hide();
$('#' + $(this).val()).show();
});

});


But it doesn't seem to be working?

My website link is: http://mykidstablet.co.uk

Answer

You're dealing with jQuery in a "noconflict" style, as such your '$' is not defined in there, change your function to read:

jQuery(document).ready(function($) {
   $('#tablets').change(function() {
       $('#LeapPad 2 Explorer,#VTech InnoTab 2').hide();
       $('#' + $(this).val()).show();
  })
});

the ready function will be passed the jQuery instance in use.

NOTE removed previously added comments with regard to IDs. See other answers for specifics.

Comments