我有一個正在加載到我的index.html中的heading.html文件。如何在已加載到另一個html文檔的html文檔上使用jquery?
heading.html
<header id="header">
<div class="logo"></div>
<nav>
<a href="#home" class="slide-section">Home</a>
<a href="#about-me" class="slide-section">About Me</a>
<a href="#why-me" class="slide-section">Why Me?</a>
<a href="#contact" class="slide-section">Contact</a>
</nav>
</header>
然後在我加載在這個文件我的JavaScript文件,它不會讓我做任何其他的功能。
functions.js
$(document).ready(function() {
$(function(){
$("#includedHeader").load("/assets/_includes/header.html");
});
$(function(){
$("#includedFooter").load("/assets/_includes/footer.html");
});
$(function(){
$("#includedWhyme").load("/assets/_includes/why-me.html");
});
$(".slide-section").click(function(){
alert('clicked');
});
});
正如你可以看到我試圖做一個警報彈出只是爲了測試它是否工作,但事實並非如此。
有沒有一種方法可以在這些正在加載的html文件上使用其他函數。
@mrlew,現在試試,我是新來的JavaScript十分感謝這個幫助。 –