sIFR 和 jQuery:动态替换文本

发布于 2024-08-20 04:44:36 字数 337 浏览 4 评论 0原文

我有一个问题。我想在按下按钮时更新计数器(用户可以看到它显示在某个 div 中)。因此,按下按钮时会发生这种情况:

$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
sIFR.replace(netto, { selector: "#photo-counter span"});

第一次会自动运行,一切正常,但是当我单击按钮时, div 不会被 sIFR 替换。

有人可以帮忙吗?

I have a problem. I would like to update a counter (seen by the user as it's displayed in a certain div) when a button is pressed. So this happens when the button is pressed:

$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
sIFR.replace(netto, { selector: "#photo-counter span"});

As on the first time this runs automatically and everything works fine, but when I click the button the div is not replaced by sIFR.

Can anybody help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

把昨日还给我 2024-08-27 04:44:36

您实际上可以这样做:

sIFR.replacements["#photo-counter span"][0].replaceText((start_index+1)+"-"+(end_index+1)+" / "+files.length);

无需更新 HTML,sIFR 会为您处理所有这些事情。

You can actually do this:

sIFR.replacements["#photo-counter span"][0].replaceText((start_index+1)+"-"+(end_index+1)+" / "+files.length);

No need to update the HTML, sIFR takes care of all that for you.

李不 2024-08-27 04:44:36

更多代码可能有助于解决这个问题。

无论如何,这是一个镜头:

将您的点击更改为实时点击:

$('#yourElement').live('click', function(){
    $("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
    sIFR.replace(netto,{
        selector: "#photo-counter span"
    });
});

希望这会有所帮助!

More code could be usefull for solving this.

Anyway, here is a shot:

Change your click to a live click:

$('#yourElement').live('click', function(){
    $("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
    sIFR.replace(netto,{
        selector: "#photo-counter span"
    });
});

Hope this helps!

浅笑依然 2024-08-27 04:44:36

这是完整的代码:

$("#arrow-left").mouseup(function() {
if(!$("#frame > *").is(":animated") && status != "fullscreen"){
$(this).css({"opacity":"1.0"});

arrowClick("left");
}};

function arrowClick(direction) {
(...) /* i dont think the problem is located somewhere here */
refreshCounter(start, end);
(...)
}

function refreshCounter(start_index, end_index) {
if(files.length > 0) {
start_i = start_index;
end_i = end_index;
if(start_index !=null && end_index != null) {
$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
sIFR.replace(netto, { selector: "#photo-counter span"});
}
}

here is the full code:

$("#arrow-left").mouseup(function() {
if(!$("#frame > *").is(":animated") && status != "fullscreen"){
$(this).css({"opacity":"1.0"});

arrowClick("left");
}};

function arrowClick(direction) {
(...) /* i dont think the problem is located somewhere here */
refreshCounter(start, end);
(...)
}

function refreshCounter(start_index, end_index) {
if(files.length > 0) {
start_i = start_index;
end_i = end_index;
if(start_index !=null && end_index != null) {
$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);  
sIFR.replace(netto, { selector: "#photo-counter span"});
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文