You can’t, as an input element doesn’t have any children (be it elements like img or pseudo elements like ::after); it just has a value, which can only be text.
BTW, you don’t have to use JS for that placeholder functionality – you can use the HTML placeholder attribute for this.
As @m3g4p0p said you don’t have pseudo elements for input type element and if you want the icon/image to be placed right after the text “Search Words” may not be possible.
However if you just want an image why not use it as a background image and position it to right side.
ananda has the right idea. While you can’t accomplish this trick with a pseudo element, you can do so with a combination of padding and background image.
Good idea indeed @ananda ! Thinking about it, you could even apply the background to the ::placeholder pseudo element (being the exception I forgot), so that it disappears when you type something into the input. Like
.keyword::-webkit-input-placeholder,
.keyword::-moz-placeholder,
.keyword::-ms-input-placeholder {
background: url('icon.png') no-repeat right center;
}
Although some browsers (IE) have implemented this as a pseudo class, where it probably won’t work. As an alternative, you might use the :placeholder-shown pseudo class to show/hide the background image, like
.keyword:placeholder-shown {
background: url('icon.png') no-repeat right center;
}
But again, browser support varies (IE). Maybe with a combination of both you’re on the safe side though.
Wow @m3g4p0p ! I Didn’t know about this ::placeholder pseudo element, will try this myself and once I understand this will post an article on this in my blog so other can get help.