document.addEventListener("DOMContentLoaded", function () {
var element = document.createElement("p");
element.textContent = "This is the element from the third.js file";
document.querySelector("body").appendChild(element);
});
document.addEventListener("DOMContentLoaded", function () {
var element = document.createElement("p");
element.textContent = "This is the element from the fourth.js file";
document.querySelector("body").appendChild(element);
});
Index.cshtml 调用
@model IEnumerable<WorkingWithVS.Models.Product>
@{Layout=null;}
<!DOCTYPE html><html><head><metaname="viewport"content="width=device-width"/><title>Working with Visual Studio</title>
**<linkrel="stylesheet"href="~/css/first.css"/><linkrel="stylesheet"href="~/css/second.css"/><scriptsrc="~/js/third.js"></script><scriptsrc="~/js/fourth.js"></script>**
</head><body><h3>Product</h3><p>Request Time:@DateTime.Now.ToString("HH:mm:ss")</p><table><thead><tr><td>Name</td><td>Price</td></tr></thead><tbody>
@foreach(var p in Model)
{
<tr><td>@p.Name</td><td>@($"{p.Price:C2}")</td></tr>
}
</tbody></table></body></html>