JavaScript的HTML渲染与" .append" - 简单code解释 [英] Javascript Rendering HTML with ".append" - Simple Code Explanation

查看:382
本文介绍了JavaScript的HTML渲染与" .append" - 简单code解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人能解释这是什么code的每一行意味着什么?我试图移动<脚本> 调用语句被我的脚本生成在我的HTML的特定位置,但code总是移动这底部一个特定的表,我认为这是与此code。我想preFER通过重写此功能,它自己定位在该点插入code,其中的<脚本方式> 出现在HTML

Can Anyone explain what each line of this code means? I'm trying to move the <script> call statement to a specific position in my HTML but the code generated by my script always moves this to the bottom of one particular table and I think it has something to do with this code. I would prefer to position it myself by rewriting this function to insert the code at the point where the <script> appears in the HTML.

function initialize(instance) {
        _this = instance;
        // build html
        var realCaller = caller != null? caller:$("body");
        var cornerClass = options.showRoundCorner? "ui-corner-all ":"";
        realCaller.append("<div id='"+windowId+"' class='window_panel "+cornerClass+options.containerClass+"'></div>");
        container = realCaller.children("div#"+windowId);

在此先感谢!

推荐答案

&LT;脚本&GT; 标记应留给无论它原是。四处移动它不会帮助。

Your <script> tag should be left wherever it was originally. Moving it around will not help.

我假设是使用jQuery的页面,但我不能从您发布什么确切地回答。

I am assuming the page is using jQuery, but I can't tell for sure from what you've posted.

首先,你需要把 id其中你想要的HTML插入(即&LT的页面元素属性; DIV ID = your_id_here&GT;&LT; / DIV&GT; 然后,改变这一行:

First, you need to put an id attribute on the page element where you want the HTML to be inserted (i.e. <div id="your_id_here"></div>. Then, change this line:

var realCaller = caller != null? caller:$("body");

要这样:

var realCaller = $('#your_id_here');

更换your_id_here与您的页面元素上设置的ID。

Replacing "your_id_here" with the ID that you set on the page element.

注意:由于您发布这么少的code,就很难知道是否这个修复将打破code等部位....

Note: Since you posted so little of your code, it's hard to know whether this "fix" will break other parts of the code....

这篇关于JavaScript的HTML渲染与&QUOT; .append&QUOT; - 简单code解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆