jquery - closest() function is not working, why? -


html:

<div class="slider">     <div class="button-wrap">         <div class="content-wrap" id="button-1">one contents</div>         <div class="controller">             <div><a mce_href="#buttton-1" href="#buttton-1">button 1 </a>             </div>         </div>     </div> </div> 

jquery:

$('#button-1').closest('.slider').css({'left':'-1200px'}); 

this not working.

i have script far

<script> jquery(function($){         $('#button-1').closest('.slider').css({'background':'#f00 !important'});         $('#button-2').closest('.slider').css({'left':'-1200px !important'}); } </script> 

the .slider element needs have position absolute or relative positioned using left property.

add following css:

.slider{     position: relative; //or absolute } 

working example: http://jsfiddle.net/u96gb/


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -