如何在文本字段值中添加img [英] How to add a img in a text field value
本文介绍了如何在文本字段值中添加img的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在文本字段的默认值内显示一张图片。这是我尝试过的,但它不起作用。
< input type =textvalue =< img src =../ images / left_arrow.gif /> Word/>
我试过转义但这不行
解决方案
您需要将图片作为元素的背景。
$ b html
< input type =textclass =with-defaultvalue =Word/> ;
css
input.with-default {
background:url('../ images / left_arrow.gif')0 0不重复;
}
另外,如果您对实际的箭头外观很灵活,你可以使用unicode字符来显示箭头,例如:b
获得更多的unicode箭头: http://www.alanwood.net/unicode/arrows.html
演示: http://jsfiddle.net/6GyVM/
I wanna show a picture inside the default value of a text field. this is what I've tried but it doesn't work.
<input type="text" value="<img src="../images/left_arrow.gif" />Word" />
I've tried escaping the " but that doesn't work
解决方案
you need to put the image as the background of the element..
html
<input type="text" class="with-default" value="Word" />
css
input.with-default{
background: url('../images/left_arrow.gif') 0 0 no-repeat;
}
Alternatively, if you are flexible about the actual arrow appearance, you could use a unicode char to display the arrow i.e. ⇐
for more unicode arrows: http://www.alanwood.net/unicode/arrows.html
demo: http://jsfiddle.net/6GyVM/
这篇关于如何在文本字段值中添加img的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文