Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery中的Asset.css_Javascript_Jquery_Css_Mootools - Fatal编程技术网

Javascript jQuery中的Asset.css

Javascript jQuery中的Asset.css,javascript,jquery,css,mootools,Javascript,Jquery,Css,Mootools,我的应用程序使用Mootools类资产在运行时包含CSS和JS文件。下一行用于包含CSS文件: var myStyleSheet = Asset.css('/styles/myStyle.css'); 我需要将这一行更改为jQuery,因为脚本的其余部分已经在jQuery中了。我们如何在jQuery中做到这一点?有一种简单的方法可以在纯javascript中实现。。试试下面的句子,瞧 var cssfile=document.createElement("link") ; cssfile.se

我的应用程序使用Mootools类资产在运行时包含CSS和JS文件。下一行用于包含CSS文件:

var myStyleSheet = Asset.css('/styles/myStyle.css');

我需要将这一行更改为jQuery,因为脚本的其余部分已经在jQuery中了。我们如何在jQuery中做到这一点?

有一种简单的方法可以在纯javascript中实现。。试试下面的句子,瞧

var cssfile=document.createElement("link") ;
cssfile.setAttribute("rel", "stylesheet");
cssfile.setAttribute("type", "text/css");
cssfile.setAttribute("href", "/styles/myStyle.css");

if (typeof cssfile!="undefined") {
document.getElementsByTagName("head")[0].appendChild(cssfile) ;
}

我肯定你把Asset.css和Asset.javascript弄混了:)是的。。。完全地。。谢谢你的编辑