[Solved] How to hide two div with the same name but in different location without knowingt the div name?


You’ll have to make sure the two divs(that contain the block#’s) have similar structures.

Then you can try something like this:

DEMO

var parentClass = $(this).parent().attr('class');
$('.'+parentClass).hide();

Edit: This fixes the problem pointed out by Metagrapher. Keep in mind though, this is not the best way of doing it, you’d be better off giving your blocks custom attributes to prevent any confusion(duplicating their id’s would do the trick, but I wouldn’t recommend it. Not really a ‘good practice’)

DEMO2

4

solved How to hide two div with the same name but in different location without knowingt the div name?