我有一個母版頁和一個JS文件,我在母版頁中添加了一個JavaScript文件的鏈接,但是在任何使用母版頁的頁面上JS沒有工作。Javascript not working from masterpage
我已經在單獨的頁面中嘗試了自己的代碼,它的工作原理。
<head runat="server">
<title></title>
<link href="../styles/StyleSheet1.css" rel="stylesheet" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="../Scripts/Menu.js"></script>
<script type="text/javascript">
function openNewWin(url) {
var x = window.open(url, 'mynewwin', 'toolbar=no,directories=no,location=no,menubar=no,left=0,top=0,resizable=no,status=no');
x.focus();
}
</script>
</head>
Menu.JS:
$(function() {
//When opening the page all level 2 and level 3 items must be hidden.
$(function() {
hideitems();
})
function hideitems() {
$('h10').hide();
$('h11').hide();
$('h12').hide();
$('h13').hide();
}
//Financial Click
$('h7').click(function() {
hideitems();
$('h10').slideToggle();
$('h11').slideToggle();
$('h12').slideToggle();
});
//Container Click
$('h8').click(function() {
hideitems();;
$('h13').slideToggle();
});
})
不工作如何?任何錯誤? – Samuel
供參考:您正在點擊處理程序內添加點擊處理程序。這不是一個好主意。 –
沒有錯誤,但功能不起作用。菜單項應該加載隱藏,然後你可以通過點擊它們來修改它們,但它們什麼都不做。 – connersz