Jump to content

Jquery Problem


smartalco

Recommended Posts

Hopefully this code is self explanatory. I have a table with a bunch of cells with divs within, and upon hovering on any one I need that div to disappear and one with and id that just has '_on' added to the id of the original div to become visible (via adding/removing the class 'hidden' that I have set). Aaaaand, it isn't working and I have no idea why. I'm fairly new to jquery, so this could be something rather stupid. Any insights?

var $music = jQuery.noConflict();$music(document).ready(function() {  $music("#program_links > tr > td > div").hover(		function() {			var id = this.attr("id");			var newid = "#" + id + "_on";			this.addClass("hidden");			$music("#"+newid).removeClass("hidden");		},function() {			var id = $music(this).attr("id");			var newid = "#" + id + "_on";			$music(this).removeClass("hidden");			$music("#"+newid).addClass("hidden");		}	); });

Link to comment
Share on other sites

Maybe it's because your HTML is invalid. you can't put a div in a table cell!!!
It's just fine to put a <div> in a table cell. It's kind of useless, but not invalid.
Link to comment
Share on other sites

Add some alerts or something to figure out what the code is doing. It may be that hovering over one div will hide it, but now that's hidden you're no longer hovering over it so it runs the other function to show it again. I'm not sure what the code is or is not doing when you run it, but add some debugging statements so that you can see exactly what the code is doing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...