如何在title属性中避免双引号 [英] How to escape double quotes in title attribute

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

问题描述

我试图在锚的title属性中使用一个包含双引号的字符串。到目前为止,我尝试了这些:

I am trying to use a string that contains double quotes in the title attribute of an anchor. So far I tried these:

<a href=".." title="Some \"text\"">Some text</a>
<!-- title looks like `Some \` --!>

<a href=".." title="Some &quot;text&quot;">Some text</a>
<!-- title looks like `Some ` --!>

请注意,使用单引号不是一个选项。

Please note that using single quotes is not an option.

推荐答案

此变体 -

<a href=".." title="Some &quot;text&quot;">Some text</a>

是正确的,它的工作原理如下 - 您在呈现的页面中看到正常的引号。

Is correct and it works as expected - you see normal quotes in rendered page.

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

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