【问题标题】:How to update HTML element with jQuery and Galleria?如何使用 jQuery 和 Galleria 更新 HTML 元素?
【发布时间】:2011-01-26 21:38:18
【问题描述】:

我正在使用 Galleria 进行幻灯片放映。我想在stage 旁边放置一个小的“更大”链接。

我有这个“更大”按钮的代码:

this.fullres = this.create('div', 'fullres');
this.get('fullres').innerHTML = '<a href="#">Larger</a>';
this.appendChild('fullres', this.fullres);

我有这段代码将每个&lt;img&gt;rel= 标记分配给页面自定义字段中的全尺寸图像URL:

<img ... rel="<?=$attachments[$i]['fullres']?>" />

使用 JQuery,我希望提取 active 图像的 rel= 标记值并附加 .fullres href 标记。这是我到目前为止的代码,但它不起作用:

var title = $(.images).attr('rel'); // pulls the fullres url from the rel tag
$('.galleria-fullres').attr('href', ); //append the galleria fullres href with the rel info

【问题讨论】:

  • 您如何获得对活动图像的引用?它有课吗?

标签: javascript jquery wordpress galleria


【解决方案1】:

Galleria 并不是这样运作的。但是您可以做的是创建一个按钮以进入全屏并在全屏时显示更大的图像。

类似这样的:

$('#galleria').galleria({
    // other galleria options here
    dataConfig: function( img ) {
        // get the fullscreen image
        return {
            big: $( img ).attr('rel')
        };
    }
});

var galleria = Galleria.get(0);

$('#fullscreen-button').click(function() {
    galleria.enterFullscreen();
});

【讨论】:

    【解决方案2】:

    我不得不说我看不出它是如何工作的......

    你知道你有一个错字:$(.images)吗?应该是$('.images')

    您是否故意遗漏了$('.galleria-fullres').attr('href', ); 的第二个参数?这不应该是$('.galleria-fullres').attr('href', title); 吗?

    jquery 如何通过类引用元素来工作?您将获得一系列元素,而不仅仅是一个。我想这只是您代码的摘录?我错过了什么吗?

    您能否发布在浏览器中看到的这些元素示例的 html?这应该是一件很容易的事情,但我真的无法仅凭这些线条看到整个画面。

    【讨论】:

      猜你喜欢
      • 2011-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多