1

guys. I have a little problem today... Code is below:

var ttw = 10;
$('.insttip:after').css('left',(ttw/2-8)+'px');

Of course, it's not working. The reason is that css() function adds css property using element's 'style' attribute. $('.insttip:after') is a pseudo element, so it has no 'style' attribute.

What should I do to solve this problem?

Thank you!

Georgy Liparteliani
  • 403
  • 2
  • 6
  • 16

1 Answers1

-1

You can't use pseudo elements in JavaScript. However, if you're looking for a workaround, here is one. Note, however, that this is if you are trying to select a text node:

var ttw = 10;
$($(".insttip")[0].nextSibling).appendTo($("<span/>")).css("left",(ttw/2-8) + "px");

That will wrap the text in a <span> tag, however.