如何在html输入值中有引号 [英] how to have quotation marks in html input values

查看:220
本文介绍了如何在html输入值中有引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题 - 从服务器端我得到一个字符串,如'hoschi'兄弟'
i想把这个字符串放入一个<输入值MYSTRING/> ,这样会导致类似于
< input valuehoschibrother/> 这显然不起作用。



任何解决方法?
会转义字符,& quot; 在值标签内工作?



感谢您的帮助,
tobi

解决方案

code>& quot; works:

 < input type =text name =last_namevalue =& quot;我的报价!& quot;/> 


i have following problem - from the server side i get a string like 'hoschi"brother' i want to put this string into a <input value"MYSTRING" />. this results in something like <input value"hoschi" brother" /> which obviously does not work.

any workarounds for this? does escaping the " character with &quot; work within the value tag?

thanks for your help, tobi

解决方案

Yes, using &quot; works:

<input type="text" name="last_name" value="&quot;My quote!&quot;" />

这篇关于如何在html输入值中有引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆