开发者

how can i put an image into select? [duplicate]

开发者 https://www.devze.com 2022-12-25 05:39 出处:网络
This question already has answers here: How to add images in select list? (15 answers) 开发者_如何学C
This question already has answers here: How to add images in select list? (15 answers) 开发者_如何学C Closed 5 years ago.

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?...


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


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.


Try creating a menu list instead:

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


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.


There is no way to make this work cross-browser, as lots of browsers restrict what you can do with the tag. FireFox browser is the only exception. But anyway, HTML tags inside options are not allowed according to the standards

0

精彩评论

暂无评论...
验证码 换一张
取 消