Select previous div that contains specific id
I am using joomla and I have the following html
<div id="ja-footerwrap"> <div class="moduletable"> <div id="bottom-slider"> <!--some contents--> </div> </div> <div class="moduletable"> <div id="bottom-slider"> <!--some contents--> </div> </div> <div class="moduletable"> <!--some contents--> </div> <!--and other divs with classes moduletable------> </div> I need to select moduletable and apply display: inline-block; only to this div that contains the id of the bottom slider . How can i do this?
+4
4 answers
First of all, you cannot have several DOM objects with the same identifier, then the first thing to change the markup is and convert id="bottom-slider" to class="bottom-slider"
Then you can change the parent divs using the moduletable and bottom-slider classes using jQuery:
$('.bottom-slider').parent('.moduletable').css({'display':'inline-block'}); Here's the fiddle: http://jsfiddle.net/9tvcf/
Hope this helps
+4