开发者

Is there a way to appendTo head?

开发者 https://www.devze.com 2023-03-03 22:01 出处:网络
I\'m working with a platform that doesn\'t allow me to e开发者_高级运维dit the source code. Is there a way to insert a line in the head element dynamically? Maybe something like below...

I'm working with a platform that doesn't allow me to e开发者_高级运维dit the source code. Is there a way to insert a line in the head element dynamically? Maybe something like below...

$("<link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet'>").appendTo("head")


Yes, .appendTo() as you have it should work perfectly fine. As well as this one:

$('head').append("<link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet'>");

but here's how I would write it:

$('head').append(
    $('<link/>', {
        href: 'http://fonts.googleapis.com/css?family=News+Cycle',
        rel: 'stylesheet'
    })
);


try this one...

$("head").append("<link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet'>")
0

精彩评论

暂无评论...
验证码 换一张
取 消