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

百般思念 提交于 2019-12-12 08:57:47

问题


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


回答1:


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




回答2:


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.




回答3:


Try creating a menu list instead:

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




回答4:


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.




回答5:


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



来源:https://stackoverflow.com/questions/2524953/how-can-i-put-an-image-into-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!