1

How do i set the left position of an element that contains a before attribute?

I've tried both the following methods with no success:

$(".tooltip:before").css({left: 80});

$(".tooltip::before").css({left: 80});

here's the css if it helps

.tooltip {
    background-color:#333;
    display: block; position: absolute; z-index: 999999; padding: 5px 10px; 
    color: #fff;
 }

// create the tip of the tooltip
.tooltip:before {
    border: solid; border-color: #333 transparent; border-width: 6px 6px 0 6px;
    position: absolute; bottom: -6px;
    z-index: 9999999;
    content: "";
    left: 0; /* use jQuery to center the tip depending on the size of the tooltip */
}
Marco
  • 2,687
  • 7
  • 45
  • 61
  • 1
    before and :after are generated element via CSS , that do not appear in the DOM, this is mainly the reason why javascript cannot access it. A good practice is to relay on a class that you toggle to apply style you wish to update on events – G-Cyrillus Apr 28 '14 at 20:37
  • possible duplicate of [Access the css ":after" selector with jQuery](http://stackoverflow.com/questions/17788990/access-the-css-after-selector-with-jquery) – KittMedia Apr 28 '14 at 20:38

0 Answers0