views:

122

answers:

5

i have this script

<select>
<option value="1">one<img src="star.gif" height="15" width="15"></img> </option>
</select>

but it doesn't work. how can i put an image into select? thanks

update:

so it's impossible?:(maybe via javascript?...

+5  A: 

you can't - DOM model doesn't allow img elements inside option elements

plodder
A: 

perhaps setting a background image with CSS - never done this so don't know if it works on not - I am guessing there will be browser issues with this too.

matpol
Option elements are too picky with styling, background images will not work. It's because an option element doesn't actually have background attributes, they have to follow the styles of the select element they fall under.
animuson
+3  A: 

Most website which associate images with a certain option in a menu use JavaScript or jQuery to change an image at the left or right of the menu whenever a new option is selected. However, it is not possible in any way to put an image inside or set a background image for an option element.

animuson
A: 

Try creating a menu list instead:

http://plugins.jquery.com/project/Plugins/category/44

DKinzer
+1  A: 

I Tryed using background-img in both [select] and [option] elements with some padding but it does work only in Firefox.

ed1nh0