简体   繁体   English

从Javascript附加HTML代码

[英]Append HTML Code from Javascript

How can i change this function which is currently appending a CSS class to a div on HTML 我如何更改此函数,该函数当前将CSS类附加到HTML上的div

if (!this.sortDisabled) {
        var $th = $(this).addClass(table.config.cssHeader);
        if (table.config.onRenderHeader) table.config.onRenderHeader.apply($th);
}

to make to append this instead of adding class "table.config.cssHeader" 使它追加而不是添加类“ table.config.cssHeader”

'&nbsp<font face="webdings">6</font>'

So my question explained is how can i get this 所以我的问题解释是我怎么能得到这个

if (!this.sortDisabled) {
    var $th = $(this).addHTMLCODE(&nbsp<font face="webdings">6</font>);
    if (table.config.onRenderHeader) table.config.onRenderHeader.apply($th);
}

It looks like you're using jQuery. 看起来您正在使用jQuery。 You're pretty close; 你很近 instead of addHTMLCODE , you need append , and you also need to quote the HTML: 代替addHTMLCODE ,您需要append ,并且还需要引用HTML:

var $th = $(this).append('&nbsp<font face="webdings">6</font>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM