Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.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/2/jquery/89.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 如何从js文件中的jquery函数调用HTML文件?_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何从js文件中的jquery函数调用HTML文件?

Javascript 如何从js文件中的jquery函数调用HTML文件?,javascript,jquery,html,Javascript,Jquery,Html,我使用require()从jquery函数调用HTML文件。但是我无法将css与HTML文件链接。运行文件后,仅显示纯HTML 我的HTML文件: <head> <script src="jquery-3.4.0.js"></script> </head> <div class="wdg-uniplick"> <table class="data-table"> <t

我使用require()从jquery函数调用HTML文件。但是我无法将css与HTML文件链接。运行文件后,仅显示纯HTML

我的HTML文件:

<head>
    <script src="jquery-3.4.0.js"></script>
</head>

<div class="wdg-uniplick">

        <table class="data-table">
            <tr>
                <th class="col-id" id="id-h">Plick Order</th>
                <th class="col-name" id="name-h">name</th>
                <th class="col-date" id="date-h">Date</th>
                <th class="col-nr-tx" id="nr-tx-h">Nr. Tx</th>
                <th class="col-amount" id="amount-h">Amount</th>
                <th class="col-state" id="state-h">State</th>
                <th class="col-actions"></th>
            </tr>
            <tr id="row-0">
                <td class="col-id" id="id-d0"></td>
                <td class="col-name" id="name-d0"></td>
                <td class="col-date" id="date-d0"></td>
                <td class="col-nr-tx" id="nr-tx-d0"></td>
                <td class="col-amount">
                    <div class="sub-2" id="ccy-d0"></div>
                    <div class="sub-1" id="amount-d0"></div>
                </td>
                <td class="col-state" id="state-d0">-</td>
                <td class="col-actions">
                    <img id="action-icons-d0" src="../img/search-20.svg">
                </td>
            </tr>
        </table>
</div>

我现在有一个content.css文件。

要链接外部
css
文件,您需要使用以下内容:

<head>
  <link rel="stylesheet" href="styles.css">
</head>

我认为您没有在html文件中添加
content.css
文件。如果您添加它,您也可以加载css

<link rel="stylesheet" type="text/css" href="content.css">

或者您可以在jquery中完成

$("<link/>", {
   rel: "stylesheet",
   type: "text/css",
   href: "content.css"
}).appendTo("head");
$(“”{
rel:“样式表”,
键入:“文本/css”,
href:“content.css”
}).附录(下称“标题”);

让内容:string='';this.content=require('../html/multilevelSCA.html')
这是从jquery函数调用html文件的正确方法吗?将html文件加载到div的正确方法是
$(“#content”).load(“content.html”)
对于您的案例,您可以像这样执行
this.getDiv().load('../html/multilevelSCA.html')
$("<link/>", {
   rel: "stylesheet",
   type: "text/css",
   href: "content.css"
}).appendTo("head");