Reputation: 301
#dock > li ul
{
position: absolute;
bottom: 0px;
left: -180px;
z-index: 1;
width: 180px;
display: none;
background-color: #F1F1F1;
border: solid 1px #969696;
padding: 0px;
margin: 0px;
list-style: none;
}
This is my css class and I want to apply a right margin dynamically using jquery. Any thoughts appreciated. I tried this:
$('#dock').children('li').children('ul').css({ 'margin-right': rmargin });
but it seems to be not working.
Upvotes: 4
Views: 489
Reputation: 40639
Try
$('#dock').find('ul').css({ 'margin-right': rmargin });
ul
must be a child
or a grand child
of #dock
other wise it may not works
In that case you can use
$('#dock > li ul').css({ 'margin-right': rmargin });
Docs http://api.jquery.com/find
Upvotes: 4
Reputation: 27364
Use it as below,
$('#dock > li ul').css({ 'margin-right': rmargin });
$('#dock > li ul')
this will select all UL
inside of LI
tag which is direct child of #dock
DOM.
Upvotes: 0