views:

205

answers:

2

use javascript or other method ? have any recommendation?

+4  A: 

IMAGE tag can not be within OPTION one (as per HTML4.01 and XHTML1.0). Apply it as a background image (of an option element) instead.

...
<option style="background-image:url(...) ...">...</option>
...

Also note that some browsers don't allow much styling on select and option elements. For example, Safari doesn't support "background-color" on option elements (there's a WebKit bug filed back in '06 :))

I've heard that Chrome has similar "issues" as well.

kangax
but it doesn't support in IE
MemoryLeak
+5  A: 

I would recommend you to use CSS. For example:

<select style="width: 100px;">
<option style="background-image: url(/images/a.png);">First option</option>
<option style="background-image: url(/images/b.png);">Second option</option>
</select>
Viliam