在WordPress中使用标题文本设置花哨的框标题
Set fancybox title using caption text in wordpress
Fancybox 有一个 title 属性,该属性从标题标签中获取值
jQuery.fn.getTitle = function() {
var arr = jQuery("a.fancybox");
jQuery.each(arr, function() {
var title = jQuery(this).children("img").attr("title");
jQuery(this).attr('title',title);
})
}
我希望能够复制标题而不是标题的属性
<dl class="gallery-item">
<dt class="gallery-icon portrait">
<a href="***.jpg" class="fancybox" rel="fancybox" title="">
<img src="*****.jpg" alt="item name"></a>
</dt>
<dd class="wp-caption-text gallery-caption">
item name
</dd>
</dl>
到目前为止,我已经尝试将标题更改为
jQuery( this ).children("img").next().text();
and
jQuery( this ).parent("dt").next().text();
但这并没有帮助。任何其他使其工作的方法。
我遇到了同样的问题。让它像这样工作:
$('dl.gallery-item').each(function(){
var caption = $(this).find('dd.wp-caption-text').text();
$(this).find('a').attr('title',caption);
$(this).find('dd.wp-caption-text').remove();
});
相关文章:
- React组件-设置页面标题
- 如何在自动完成时设置属性标题
- 是否可以像在$routeProvider中一样在 Angular AMD 中设置页面标题
- 如何在动态树标题中的输入字段上设置焦点
- 设置PDF页面的浏览器标题
- Ext JS 5.1:当可折叠为true时,无法对面板进行标题设置
- 使用javascript设置html页面的标题
- 正在为禁用的输入设置标题属性
- 如何打开jQuery对话框并将其标题自动设置为HTML标记中的属性
- 如何在dgrid中设置列内容的样式,而不设置列标题的样式
- 设置 Jquery 对话框标题栏样式
- 为HTML文本区域设置标题属性的样式
- jQuery ticker - 如何为 #ticker 标题设置 URL
- H1 标题设置不正确
- AG-Grid 将列标题设置为复选框,然后执行全选或取消全选列,而不是仅组
- MVC4引导JQuery-将下拉标题设置为所选项目
- 在JSP中将按钮标题设置为bean消息
- 将HTML中的按钮标题设置为非格式化文本
- Google 日历标题设置为“无显示”
- 如何为我的d3图表标题设置文本颜色