简体   繁体   English

对于<a>标签的</a> Title属性是否有效, <a>可以保存html标签</a> <a><br></a> <a>换新线</a>

[英]Is it valid for Title attribute for <a> tag to hold html tags like <br> for new line

My question here is it really valid for a title attribute to hold html tags like break tag for new line. 我的问题是,它对于一个title属性来说非常有效,可以为新行保存html标签,例如break标签。

  <a href="#" title="hello <br> how are you" target="xxx"></a>

If its valid then break tag shows in tool tip which i want to avoid but still need a new line. 如果它的有效然后中断标记显示在工具提示中,我想避免但仍需要一个新行。

I am using jQuery. 我正在使用jQuery。

I referred a link http://jsfiddle.net/roXon/N8Q2z/ in which i gave break tags in title. 我引用了一个链接http://jsfiddle.net/roXon/N8Q2z/ ,其中我在标题中给出了break标签。 It just works fine in achieving new line without break tag being displayed in tool tip. 只需在工具提示中显示没有中断标记的新行就可以正常工作。

But not sure which part of the code is avoiding break tags in tool tip. 但不确定代码的哪一部分是避免工具提示中的中断标记。

Can you please let me know which piece of code in jquery actually avoids break tags being displayed in tool tips as i am new to jquery. 能不能让我知道jquery中的哪一段代码实际上避免了在工具提示中显示破解标记,因为我是jquery的新手。

Would appreciate all your help!! 非常感谢您的帮助!!

Thanks in advance... 提前致谢...

Try using <br /> but use the values &lt; 尝试使用<br />但使用值&lt; for < and &gt; for <&gt; for > . > This will means that when the title is put into your tooltip it will be the correct format, and its valid! 这意味着当title放入您的工具提示时,它将是正确的格式,并且有效!

Tested in IE7+, Chrome, Firefox. 在IE7 +,Chrome,Firefox中测试过。

jsFiddle 的jsfiddle

<a title="hello&lt;br/&gt;how are you" class="printbtn" href="#">Print results</a><br>

Use &#13; 使用&#13; or &#xD; 或者&#xD;

<a href="#" title="hello &#13; how are you" target="xxx"></a>

Attribute values cannot contain tags. 属性值不能包含标记。 You can put new lines in the attribute values, but that's probably not a good idea. 您可以在属性值中添加新行,但这可能不是一个好主意。

It's a good time to think about why you want to put tags in the attribute and what you want to accomplish. 现在是思考为什么要在标签中添加标签以及想要完成什么的好时机。 I'm sure there are better ways. 我相信有更好的方法。

Title attribute should be a text . 标题属性应该是text Title Attribute Ref 标题属性参考

title = text [CS]; title = text [CS]; This attribute offers advisory information about the element for which it is set. 此属性提供有关为其设置的元素的建议信息。 Values of the title attribute may be rendered by user agents in a variety of ways. 用户代理可以以各种方式呈现标题属性的值。 For instance, visual browsers frequently display the title as a "tool tip" (a short message that appears when the pointing device pauses over an object). 例如,可视浏览器经常将标题显示为“工具提示”(当指点设备暂停在对象上时出现的短消息)。 Audio user agents may speak the title information in a similar context. 音频用户代理可以在类似的上下文中说出标题信息。 For example, setting the attribute on a link allows user agents (visual and non-visual) to tell users about the nature of the linked resource: 例如,在链接上设置属性允许用户代理(可视和非可视)告知用户链接资源的性质:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM