/* 作者:桂林众腾网络-江斌 时间:2018年11月17日 qq:261619000 */ ;(function ($) { $.fn.ztmenu=function (options) { var defaults={ objname:"", //导航父级名称 menuname:"", //触发导航按钮 menubj:"", //弹出导航后显示背景 bodywidth:1000,//网页宽度触发显示手机导航 }; var endoptions=$.extend(defaults,options); $(endoptions.menuname).click(function(){ $(endoptions.objname).slidetoggle(100); if($(this).attr("data-number")==""){ $(this).css("background-image","url(public/home/image/menub.png)").attr("data-number","1"); $(endoptions.menubj).css("display","block"); }else{ $(this).css("background-image","url(public/home/image/menubs.png)").attr("data-number",""); $(endoptions.objname).children("li").children("ul").css("display","none"); $(endoptions.menubj).css("display","none"); } }); $(this).click(function(event){ event.stoppropagation(); if ($(this).parent().children().find("li").length>0 && $(window).width() endoptions.bodywidth){//窗口宽度没有加入滚动条15px $(endoptions.objname).css("display","inline-block").children("li").find("ul").css("display",""); $(endoptions.menuname).attr('data-number',""); $(endoptions.menubj).css("display","none"); }else{ if($(endoptions.menuname).attr('data-number') == ''){ $(endoptions.menuname).css("background-image","url(public/home/image/menubs.png)").attr("data-number",""); $(endoptions.objname).css("display","none"); } } }); } })(jquery);