简体   繁体   English

在Magnific弹出标题属性中使用html

[英]Using html in Magnific pop up title attribute

I need to wrap certain bits of my title attribute in html tags in order to style them for when I click an element and it pops up on Magnific Popup. 我需要将我的title属性的某些位包装在html标签中,以便在单击元素并将其弹出在Magnific Popup上时为其设置样式。 I am trying something like bellow at the moment: 我现在正在尝试类似波纹管的东西:

 <a href="path/to/img" title='<span class="date">2016 -</span> Title text goes here'> Content goes here </a>

However, if I add html tags in the title attribute as I have above it will then show them with the html tags and title text when hovering the element with the title attribute like bellow: 但是,如果我像上面那样在title属性中添加html标签,则将鼠标悬停在具有title属性的元素(例如下面)时,它们将显示html标签和标题文本:

<span class="date">2016 -</span> Title text goes here

How could I implement this so that I can still style the date and have it rendering without the html tags on hover like: 我该如何实现这一点,以便我仍然可以设置日期的样式并在没有html标记的情况下呈现日期,例如:

2016 - Title text goes here

I would suggest using javascript for that an in your initialization code do something like that: 我建议您在初始化代码中使用javascript做类似的事情:

titleSrc: function() {
    return "<span class='date'>2016 -</span> Title text goes here";
}

As said in documentation 文档中所述

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

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