jquery는 간단한 보조 탐색 드롭다운 메뉴를 구현합니다.
이 문서의 예에서는 jquery가 간단한 보조 탐색 드롭다운 메뉴 효과를 구현하는 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 세부 내용은 다음과 같습니다.
jQuery 코드로 구현된 보조 탐색 메뉴 효과는 매우 간단합니다. 단순한 스타일을 좋아하는 친구는 다운로드할 수 있습니다. 메뉴는 최대 2개 레벨까지 지원하며, CSS의 협력도 매우 중요합니다. 코드를 원하시면 복사하시면 됩니다.
런닝 효과 스크린샷은 다음과 같습니다.
온라인 데모 주소는 다음과 같습니다.
http://demo.jb51.net/js/2015/jquery-2jxl-menu-codes/
구체적인 코드는 다음과 같습니다.
<title>jquery二级导航菜单</title> <style> .ddsmoothmenu { MARGIN: 0px auto; FONT: 12px Verdana; WIDTH: 730px } .ddsmoothmenu UL { PADDING-RIGHT: 0px; PADDING-LEFT: 0px;BACKGROUND: #2b9801; Z-INDEX: 100; FLOAT: left; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none } .ddsmoothmenu UL LI { DISPLAY: block; FLOAT: left; WIDTH: 81px; LINE-HEIGHT: 31px; POSITION: relative; TEXT-ALIGN: center } HTML .ddsmoothmenu UL LI { FLOAT: left; WIDTH: 81px; LINE-HEIGHT: 31px; POSITION: relative; TEXT-ALIGN: center } .ddsmoothmenu UL LI A { DISPLAY: block; FONT-WEIGHT: bold; WIDTH: 81px; TEXT-DECORATION: none } .ddsmoothmenu UL LI A:link { COLOR: #fff } .ddsmoothmenu UL LI A:visited { COLOR: #fff } .ddsmoothmenu UL LI A:hover { COLOR: #ffff00 } .ddsmoothmenu UL LI UL { LEFT: 0px; VISIBILITY: hidden; POSITION: absolute } .ddsmoothmenu UL LI UL LI { BACKGROUND: #2b9801; FLOAT: left; WIDTH: 81px; LINE-HEIGHT: 25px; BORDER-BOTTOM: #96d47d 1px solid } .ddsmoothmenu UL LI UL LI A { DISPLAY: block; WIDTH: 81px; TEXT-DECORATION: none } .ddsmoothmenu UL LI UL LI A:hover { BACKGROUND: #51b228 } .ddsmoothmenu UL LI UL LI UL { TOP: 0px } .downarrowclass { DISPLAY: none; POSITION: absolute } .rightarrowclass { DISPLAY: none; POSITION: absolute } .ddshadow { BACKGROUND: silver; LEFT: 0px; WIDTH: 0px; POSITION: absolute; TOP: 0px; HEIGHT: 0px } .toplevelshadow { opacity: 0.8 } </style> <SCRIPT src="jquery1.3.2.js" type=text/javascript></SCRIPT> <SCRIPT type=text/javascript> var ddsmoothmenu={ //Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs): arrowimages: {down:['downarrowclass', '', 0], right:['rightarrowclass', '']}, transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds shadow: {enabled:false, offsetx:5, offsety:5}, detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1, //detect WebKit browsers (Safari, Chrome etc) getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs var $menucontainer=$('#'+setting.contentsource[0]) //reference empty div on page that will hold menu $menucontainer.html("Loading Menu...") $.ajax({ url: setting.contentsource[1], //path to external menu file async: true, error:function(ajaxrequest){ $menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText) }, success:function(content){ $menucontainer.html(content) ddsmoothmenu.buildmenu($, setting) } }) }, buildshadow:function($, $subul){ }, buildmenu:function($, setting){ var smoothmenu=ddsmoothmenu var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL var $headers=$mainmenu.find("ul").parent() $headers.each(function(i){ var $curobj=$(this).css({zIndex: 100-i}) //reference current LI header var $subul=$(this).find('ul:eq(0)').css({display:'block'}) this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()} this.istopheader=$curobj.parents("ul").length==1? true : false //is top level header? $subul.css({top:this.istopheader? this._dimensions.h+"px" : 0}) $curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images '<img src="'+ (this.istopheader? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1]) +'" class="' + (this.istopheader? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0]) + '" style="border:0;" />' ) if (smoothmenu.shadow.enabled){ this._shadowoffset={x:(this.istopheader?$subul.offset().left+smoothmenu.shadow.offsetx : this._dimensions.w), y:(this.istopheader? $subul.offset().top+smoothmenu.shadow.offsety : $curobj.position().top)} //store this shadow's offsets if (this.istopheader) $parentshadow=$(document.body) else{ var $parentLi=$curobj.parents("li:eq(0)") $parentshadow=$parentLi.get(0).$shadow } this.$shadow=$('<div class="ddshadow'+(this.istopheader? ' toplevelshadow' : '')+'"></div>').prependTo($parentshadow).css({left:this._shadowoffset.x+'px', top:this._shadowoffset.y+'px'}) //insert shadow DIV and set it to parent node for the next shadow div } $curobj.hover( function(e){ var $targetul=$(this).children("ul:eq(0)") this._offsets={left:$(this).offset().left, top:$(this).offset().top} var menuleft=this.istopheader? 0 : this._dimensions.w menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent if ($targetul.queue().length<=1){ //if 1 or less queued animations $targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime) if (smoothmenu.shadow.enabled){ var shadowleft=this.istopheader? $targetul.offset().left+ddsmoothmenu.shadow.offsetx : menuleft var shadowtop=this.istopheader?$targetul.offset().top+smoothmenu.shadow.offsety : this._shadowoffset.y if (!this.istopheader && ddsmoothmenu.detectwebkit){ //in WebKit browsers, restore shadow's opacity to full this.$shadow.css({opacity:1}) } this.$shadow.css({overflow:'', width:this._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px'}).animate({height:this._dimensions.subulh+'px'}, ddsmoothmenu.transition.overtime) } } }, function(e){ var $targetul=$(this).children("ul:eq(0)") $targetul.animate({height:'hide', opacity:'hide'}, ddsmoothmenu.transition.outtime) if (smoothmenu.shadow.enabled){ if (ddsmoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them this.$shadow.children('div:eq(0)').css({opacity:0}) } this.$shadow.css({overflow:'hidden'}).animate({height:0}, ddsmoothmenu.transition.outtime) } } ) //end hover }) //end $headers.each() $mainmenu.find("ul").css({display:'none', visibility:'visible'}) }, init:function(setting){ if (typeof setting.customtheme=="object" && setting.customtheme.length==2){ var mainmenuid='#'+setting.mainmenuid document.write('<style type="text/css">\n' +mainmenuid+', '+mainmenuid+' ul li a {background:'+setting.customtheme[0]+';}\n' +mainmenuid+' ul li a:hover {background:'+setting.customtheme[1]+';}\n' +'</style>') } jQuery(document).ready(function($){ //override default menu colors (default/hover) with custom set? if (typeof setting.contentsource=="object"){ //if external ajax menu ddsmoothmenu.getajaxmenu($, setting) } else{ //else if markup menu ddsmoothmenu.buildmenu($, setting) } }) } } //end ddsmoothmenu variable //Initialize Menu instance(s): ddsmoothmenu.init({ mainmenuid: "smoothmenu1", //menu DIV id customtheme: [], //override default menu CSS background values? Uncomment: ["normal_background", "hover_background"] contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"] }) </SCRIPT> <DIV class=ddsmoothmenu id=smoothmenu1> <UL> <LI><A href="#">首页</A> </LI> <LI><A href="#">一年级</A> <UL> <LI><A href="#">一年级1班</A> </LI> <LI><A href="#">一年级2班</A> </LI> <LI><A href="#">一年级3班</A> </LI> <LI><A href="#">一年级4班</A> </LI> <LI><A href="#">一年级5班</A> </LI></UL></LI> <LI><A href="#">二年级</A> <UL> <LI><A href="#">二年级1班</A> </LI> <LI><A href="#">二年级2班</A> </LI> <LI><A href="#">二年级3班</A> </LI> <LI><A href="#">二年级4班</A> </LI> <LI><A href="#">二年级5班</A> </LI></UL></LI> <LI><A href="#">三年级</A> <UL> <LI><A href="#">三年级1班</A> </LI> <LI><A href="#">三年级2班</A> </LI> <LI><A href="#">三年级3班</A> </LI> <LI><A href="#">三年级4班</A> </LI> <LI><A href="#">三年级5班</A> </LI></UL></LI> <LI><A href="#">四年级</A> <UL> <LI><A href="#">四年级1班</A> </LI> <LI><A href="#">四年级2班</A> </LI> <LI><A href="#">四年级3班</A> </LI> <LI><A href="#">四年级4班</A> </LI> <LI><A href="#">四年级5班</A> </LI></UL></LI> <LI><A href="#">五年级</A> <UL> <LI><A href="#">五年级1班</A> </LI> <LI><A href="#">五年级2班</A> </LI> <LI><A href="#">五年级3班</A> </LI> <LI><A href="#">五年级4班</A> </LI> <LI><A href="#">五年级5班</A> </LI></UL></LI> <LI><A href="#">六年级</A> <UL> <LI><A href="#">六年级1班</A> </LI> <LI><A href="#">六年级2班</A> </LI> <LI><A href="#">六年级3班</A> </LI> <LI><A href="#">六年级4班</A> </LI> <LI><A href="#">六年级5班</A> </LI></UL></LI> <LI><A href="#">七年级</A> <UL> <LI><A href="#">七年级1班</A> </LI> <LI><A href="#">七年级2班</A> </LI> <LI><A href="#">七年级3班</A> </LI> <LI><A href="#">七年级4班</A> </LI> <LI><A href="#">七年级5班</A> </LI></UL></LI> </UL> </DIV>
이 기사가 모든 사람의 jquery 프로그래밍 설계에 도움이 되기를 바랍니다.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











WPS 테이블 드롭다운 메뉴 만드는 방법: 드롭다운 메뉴를 설정하려는 셀을 선택한 후 "데이터", "유효성"을 차례로 클릭한 후 팝업 대화 상자에서 해당 설정을 지정합니다. 메뉴를 아래로 내리세요. 강력한 사무용 소프트웨어인 WPS는 문서, 통계 데이터 표 등을 편집하는 기능을 갖추고 있어 텍스트, 데이터 등을 처리해야 하는 많은 사람들에게 많은 편의를 제공합니다. WPS 소프트웨어를 능숙하게 사용하여 많은 편의를 제공하려면 WPS 소프트웨어의 다양한 기본 작동을 마스터할 수 있어야 합니다. 이 기사에서는 편집자가 WPS 소프트웨어 사용 방법을 공유합니다. 나타나는 WPS 표에서 아래 메뉴 작업을 수행합니다. WPS 양식을 연 후 먼저

jQuery 참조 방법에 대한 자세한 설명: 빠른 시작 가이드 jQuery는 웹 사이트 개발에 널리 사용되는 JavaScript 라이브러리로, JavaScript 프로그래밍을 단순화하고 개발자에게 풍부한 기능을 제공합니다. 이 기사에서는 jQuery의 참조 방법을 자세히 소개하고 독자가 빠르게 시작할 수 있도록 구체적인 코드 예제를 제공합니다. jQuery 소개 먼저 HTML 파일에 jQuery 라이브러리를 도입해야 합니다. CDN 링크를 통해 소개하거나 다운로드할 수 있습니다.

jQuery에서 PUT 요청 방법을 사용하는 방법은 무엇입니까? jQuery에서 PUT 요청을 보내는 방법은 다른 유형의 요청을 보내는 것과 유사하지만 몇 가지 세부 사항과 매개 변수 설정에 주의해야 합니다. PUT 요청은 일반적으로 데이터베이스의 데이터 업데이트 또는 서버의 파일 업데이트와 같은 리소스를 업데이트하는 데 사용됩니다. 다음은 jQuery에서 PUT 요청 메소드를 사용하는 구체적인 코드 예제입니다. 먼저 jQuery 라이브러리 파일을 포함했는지 확인한 다음 $.ajax({u를 통해 PUT 요청을 보낼 수 있습니다.

jQuery를 사용하여 요소의 높이 속성을 제거하는 방법은 무엇입니까? 프런트엔드 개발에서는 요소의 높이 속성을 조작해야 하는 경우가 종종 있습니다. 때로는 요소의 높이를 동적으로 변경해야 할 수도 있고 요소의 높이 속성을 제거해야 하는 경우도 있습니다. 이 기사에서는 jQuery를 사용하여 요소의 높이 속성을 제거하는 방법을 소개하고 구체적인 코드 예제를 제공합니다. jQuery를 사용하여 높이 속성을 연산하기 전에 먼저 CSS의 높이 속성을 이해해야 합니다. height 속성은 요소의 높이를 설정하는 데 사용됩니다.

제목: jQuery 팁: 페이지에 있는 모든 태그의 텍스트를 빠르게 수정하세요. 웹 개발에서는 페이지의 요소를 수정하고 조작해야 하는 경우가 많습니다. jQuery를 사용할 때 페이지에 있는 모든 태그의 텍스트 내용을 한 번에 수정해야 하는 경우가 있는데, 이는 시간과 에너지를 절약할 수 있습니다. 다음은 jQuery를 사용하여 페이지의 모든 태그 텍스트를 빠르게 수정하는 방법을 소개하고 구체적인 코드 예제를 제공합니다. 먼저 jQuery 라이브러리 파일을 도입하고 다음 코드가 페이지에 도입되었는지 확인해야 합니다. <

제목: jQuery를 사용하여 모든 태그의 텍스트 내용을 수정합니다. jQuery는 DOM 작업을 처리하는 데 널리 사용되는 인기 있는 JavaScript 라이브러리입니다. 웹 개발을 하다 보면 페이지에 있는 링크 태그(태그)의 텍스트 내용을 수정해야 하는 경우가 종종 있습니다. 이 기사에서는 jQuery를 사용하여 이 목표를 달성하는 방법을 설명하고 구체적인 코드 예제를 제공합니다. 먼저 페이지에 jQuery 라이브러리를 도입해야 합니다. HTML 파일에 다음 코드를 추가합니다.

데이터를 자동으로 연결하도록 Excel 드롭다운 메뉴를 설정하는 방법은 무엇입니까? 우리는 엑셀을 사용할 때 데이터를 빠르게 조작하기 위해 드롭다운 메뉴를 사용합니다. 그런데 많은 사용자들이 드롭다운 메뉴를 설정하여 데이터를 자동으로 연결하는 방법에 대해서도 문의합니다. 이 사이트에서는 Excel 드롭다운 메뉴에 대한 자동 데이터 연결을 설정하는 방법을 사용자에게 주의 깊게 소개합니다. 데이터를 자동으로 연결하도록 Excel 드롭다운 메뉴를 설정하는 방법 1. Excel 테이블을 엽니다. 2. 빈 셀에 관련 데이터를 입력합니다. 3. 그런 다음 드롭다운 목록을 추가하려는 셀을 선택합니다. 4. 메뉴바에서 [데이터]-[데이터 검증]을 클릭하세요. 5. 확인 조건은 [순서]를 선택하세요. 6. 그림의 화살표가 가리키는 버튼을 클릭하고 선택하세요.

jQuery는 웹 페이지에서 DOM 조작 및 이벤트 처리를 처리하는 데 널리 사용되는 인기 있는 JavaScript 라이브러리입니다. jQuery에서 eq() 메서드는 지정된 인덱스 위치에서 요소를 선택하는 데 사용됩니다. 구체적인 사용 및 적용 시나리오는 다음과 같습니다. jQuery에서 eq() 메서드는 지정된 인덱스 위치에 있는 요소를 선택합니다. 인덱스 위치는 0부터 계산되기 시작합니다. 즉, 첫 번째 요소의 인덱스는 0이고 두 번째 요소의 인덱스는 1입니다. eq() 메소드의 구문은 다음과 같습니다: $("s
