【问题标题】:How can I force the contents of a div to refresh?如何强制刷新 div 的内容?
【发布时间】:2013-05-16 09:24:57
【问题描述】:

我现在可以动态替换 html 文本 (How can I replace html text dynamically?),但是当 inputQuery val 替换文本/标题/标题时,我也需要刷新推文。 IOW,我可以将文本从“jquery”更改为“html5”,但我显示的推文仍然是 jquery 推文。我怎样才能让那个 div 刷新?内容位于 jqueryUI 选项卡中,但这可能无关紧要。

更新

这就是我所拥有的:

$("#inputQuery").keyup(function (e) {
    if (e.keyCode == 13) {
        $("#Twitterpated h3").text(this.value);
        inputQueryText = this.value; 
        loadTweets(); // this concatenates the bits necessary, with inputQueryText in the middle (the "screen name" part)
    }
});

...它不起作用。也就是说,文本变了,拼接的twitterUrl是正确的,但是页面没有刷新。

我开始思考 - 也许问题是我没有清除以前的条目。如何清除调用 loadTweets() 的 html?我试过了:

$("#Twitterpated h3").html("");

...和:

$("#Twitterpated h3").html().val("");

...无济于事。

【问题讨论】:

  • 您最初使用什么代码填充推文?
  • @KevinB:我调用了一个函数;第一次工作正常。当我更新 html 文本时,我再次调用该函数,并使用 URL 的更新值,但它不会刷新。这是我想要的 val,但页面没有刷新,所以没用。
  • 您没有向我们展示上述代码也无济于事。
  • 我希望有一些读心者一起阅读。

标签: jquery html dynamic twitter jquery-ui-tabs


【解决方案1】:

不确定我是否理解,但这就是我的想法......

当 inputQuery 中的值发生变化时,以与首次加载相同的方式刷新推文 DIV。像这样的东西应该可以解决问题:

$('#inputQueryId').change(function () {
    // your code here, let's say:
    RefreshTweets($(this).val());
});

【讨论】:

    猜你喜欢
    • 2010-11-24
    • 2016-02-21
    • 2018-03-27
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    相关资源
    最近更新 更多