4

I'm using joomla and I have as 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 have to select the moduletable and have to apply display: inline-block; only to that div which contains with an id of bottom-slider. How can I do that?

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231

4 Answers4

4

First of all you cannot have multiple DOM objects with the same ID then the first thing is change the markup and transform the id="bottom-slider" to class="bottom-slider"

Then you can change the parent divs with class moduletable and bottom-slider childrens using jQuery:

$('.bottom-slider').parent('.moduletable').css({'display':'inline-block'});

Here the fiddle: http://jsfiddle.net/9tvcf/

Hope this helps

Mangiucugna
  • 1,732
  • 1
  • 14
  • 23
  • thanks. but If I was able to select that with css would be too good but still in css3 this feature is not submitted – Bhojendra Rauniyar Jul 26 '13 at 07:02
  • Unfortunately there is no way to select the parent div in CSS3 http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector – Mangiucugna Jul 26 '13 at 07:03
1

If you are using jQuery you can directly do

$('.bottom-slider').css({'display':'inline-block'});

PS: Change id to class.

aBhijit
  • 5,261
  • 10
  • 36
  • 56
0

Using css4 you will be able to do it with pure css too.

.module-table! > #bottom-slider {
display:inline-block;
}
user1721135
  • 6,864
  • 8
  • 34
  • 63
  • unfortunately there is no browser support now, neither chrome support this CSS4 selector that BTW would be .module-table! > .bottom-slider – Mangiucugna Jul 26 '13 at 07:07
0

I hope in future like this selector would be selected as this

.bottom-slider - .moduletable{/*css here*/}

This method would be the best because there is + symbol for children selection.

Like as ~ we would hope to be placed ^

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231