7

Why doesnt it work? Is there a work around for this without adding an extra element?

http://jsfiddle.net/86gb2/

Rane
  • 255
  • 1
  • 6
  • 17

2 Answers2

13

In your fiddle the following declaration is probably not doing what you expect.

select:after {content: "This doesn't work";}

This will actually append the text after the content of the select box, not after the select box itself. So that text is being added after the last option in the markup. (Which of course is neither valid, nor will it be rendered by the browser.)

In other words if you had this markup:

<a href="#">My link</a>

and this CSS:

a:after {content: " has now been appended to";}

What is actually happening is this:

<a href="#">My link has now been appended to</a>
Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55
  • I know that. But i didnt think of it when it was for the select element..I used a wrapper instead, then it worked like i wanted :) – Rane Oct 05 '12 at 14:41
-3

I would recommend to use jQuery API for such things:

$(document).ready(function(){
    $("select").after("<div>this doesnt work, or does it?</div>");
});​
mschmoock
  • 20,084
  • 6
  • 33
  • 35