日期:2014-05-16 浏览次数:20764 次
$(document).ready(function(){
var wraper1 = '<div class="gt-nav-wraper"><div class="gt-nav-sub1"></div><div class="gt-nav-sub2">';
var wraper2 = '</div><div class="gt-nav-sub3"></div></div>';
$("#n1").html(wraper1+$("#n1").html()+wraper2);
$(".mainNav a").each(function(){
$(this).bind("mouseover",function(e){
$('.gt-nav-wraper').replaceWith($('.gt-nav-wraper').find('img'));
$(this).html(wraper1+$(this).html()+wraper2);
var currentMenuNo = parseInt(this.id.substring(1));
$(".secondNav div").each(function(){
$(this).hide();
});
$("#subNav"+currentMenuNo).show();
}).live("click",function(e){
alert($(this).attr("id"));
return false;
});;
});
});
<div class="mainNav">
<a href="#" target="_blank" id="n1"><img src="images/nav_1.gif" /></a>
<a href="#" target="_blank" id="n2"><img src="images/nav_2.gif" /></a>
<a href="#" target="_blank" id="n3"><img src="images/nav_3.gif" /></a>
<a href="#" target="_blank" id="n4"><img src="images/nav_4.gif" /></a>
<a href="#" target="_blank" id="n5"><img src="images/nav_5.gif" /></a>
<a href="#" target="_blank" id="n6"><img src="images/nav_6.gif" /></a>
<a href="#" target="_blank" id="n7"><img src="images/nav_7.gif" /></a>
<a href="#" target="_blank" id="n8"><img src="images/nav_8.gif" /></a>
<a href="#" target="_blank" id="n9"><img src="images/nav_9.gif" /></a>
<a href="#" target="_blank" id="n10"><img src="images/nav_10.gif"/></a>
<a href="#" target="_blank" id="n11"><img src="images/nav_11.gif"/></a>
<a href="#" target="_blank" id="n12"><img src="images/nav_12.gif"/></a>
<a href="#" target="_blank" id="n13"><img src="images/nav_13.gif"/></a>
$(document).ready(function () {
var wraper1 = '<div class="gt-nav-wraper"><div class="gt-nav-sub1"></div><div class="gt-nav-sub2">';
var wraper2 = '</div><div class="gt-nav-sub3"></div></div>';
$("#n1").html(wraper1 + $("#n1").html() + wraper2);
///////事件独立出来
function mouseover(e) {
&nb