【问题标题】:html() is not working in Firefox when i`m using script tag当我使用脚本标签时,html() 在 Firefox 中不起作用
【发布时间】:2020-04-09 12:16:33
【问题描述】:

我正在使用jsrender,在 Chrome 中一切正常,但在 Firefox 中却无法正常工作。

如果我尝试在控制台(使用 Firefox)中获取 $('#theTmpl').html(),它即将到来“”。但在 Chrome 中完美运行。

铬:

火狐:

代码:

<script id="theTmpl" type="text/x-jsrender" data-jsv-tmpl="jsvTmpl">
    <div>
            {{if TotalNumberOfResults == 0 }}
            <h3>
                No Results
            </h3>
        </div><div>
            {{else}}
            <h3 id="resultFoundText" style="display:none">
                Showing [[numberone]] of [[numbertwo]] matching [[searchtext]] :
            </h3>
            {{/if}}
        </div><div class="search-result-row">
            {{for Results}}
            <h4>
                {{for Fields}}
                {{if Key == 'item_indexed_link_t'}}
                <a href="{{:Value}}" class="link-text">
                    {{/if}}
                    {{/for}}
                    {{for Fields}}
                    {{if Key == 'title_t'}}
                    {{:Value}}
                    {{/if}}
                    {{/for}}
                    {{for Fields}}
                    {{if Key == 'item_indexed_link_t'}}
                </a>
                {{/if}}
                {{/for}}
                {{for Fields}}
                {{if Key == '_templatename'}}
                <span class="category">{{:Value}}</span>
                {{/if}}
                {{/for}}
            </h4>
            {{for Fields}}
            {{if Key == 'description_t'}}
            <p>{{:Value}}</p>
            {{/if}}
            {{/for}}
            {{/for}}
        </div><div id="loadMoreResult">
            {{if TotalNumberOfResults != 0 }}
            <a class="medtouch-btn danger" onclick="FillSearch(false,  null, true)">Load More Result</a>
            {{/if}}
        </div></script>

【问题讨论】:

  • 为我工作。如果您使用脚本调用 $('#theTmpl').html() 创建一个 jsfiddle,它在 Firefox 中是否可以工作?如果没有,您可以发布示例....
  • 也可以在这里使用,但您可能更喜欢text() 来访问

标签: javascript jsrender


【解决方案1】:

使用JQueryFirefox 很多年都会遇到这个问题。

尝试将 JQueryFirefox 更新到最新版本。

不要尝试JQuery

document.getElementById("theTmpl");

类似的问题:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-27
    • 2022-01-05
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    相关资源
    最近更新 更多