Cara Memasang Menu Responsive Dropdown + Kotak Pencarian Menggunakan Selectnav Javascript
March 27, 2018
Cara Memasang Menu Responsive + Kotak Pencarian Menggunakan Selectnav Javascript. Selectnav Menu Responsive. Penampakannya seperti gambar di bawah ini.
1. Tema > Edit HTML
2. Copas kode JavaScript berikut ini di atas kode </body>
3. Copas kode CSS Menu Responsive berikut ini di atas kode ]]></b:skin>
4. Copas kode HTML Menu Responsive berikut ini di bawah kode </header> atau setelah kode header blog Anda.
Kode LAYOUT
Simpan di atas kode ]]></b:skin> atau dijajaran kode body#layout yang sudah ada.
Save!
Klik Layout/Tata Letak untuk memasukkan daftar menu/link menu menggunakan Link List Widget yang sudah ada.
Demikian Cara Memasang Menu Responsive Dropdown + Kotak Pencarian Menggunakan Selectnav Javascript. Good Luck & Happy Blogging! (www.contohblog.com).
Sumber
1. Tema > Edit HTML
2. Copas kode JavaScript berikut ini di atas kode </body>
<script type='text/javascript'>
//<![CDATA[
// Plugin: SelectNav.js
window.selectnav=function(){"use strict";var e=function(e,t){function c(e){var t;if(!e)e=window.event;if(e.target)t=e.target;else if(e.srcElement)t=e.srcElement;if(t.nodeType===3)t=t.parentNode;if(t.value)window.location.href=t.value}function h(e){var t=e.nodeName.toLowerCase();return t==="ul"||t==="ol"}function p(e){for(var t=1;document.getElementById("selectnav"+t);t++);return e?"selectnav"+t:"selectnav"+(t-1)}function d(e){a++;var t=e.children.length,n="",l="",c=a-1;if(!t){return}if(c){while(c--){l+=o}l+=" "}for(var v=0;v<t;v++){var m=e.children[v].children[0];if(typeof m!=="undefined"){var g=m.innerText||m.textContent;var y="";if(r){y=m.className.search(r)!==-1||m.parentNode.className.search(r)!==-1?f:""}if(i&&!y){y=m.href===document.URL?f:""}n+='<option value="'+m.href+'" '+y+">"+l+g+"</option>";if(s){var b=e.children[v].children[1];if(b&&h(b)){n+=d(b)}}}}if(a===1&&u){n='<option value="">'+u+"</option>"+n}if(a===1){n='<select class="selectnav" id="'+p(true)+'">'+n+"</select>"}a--;return n}e=document.getElementById(e);if(!e){return}if(!h(e)){return}if(!("insertAdjacentHTML"in window.document.documentElement)){return}document.documentElement.className+=" js";var n=t||{},r=n.activeclass||"active",i=typeof n.autoselect==="boolean"?n.autoselect:true,s=typeof n.nested==="boolean"?n.nested:true,o=n.indent||"?",u=n.label||"Menu",a=0,f=" selected ";e.insertAdjacentHTML("afterend",d(e));var l=document.getElementById(p());if(l.addEventListener){l.addEventListener("change",c)}if(l.attachEvent){l.attachEvent("onchange",c)}return l};return function(t,n){e(t,n)}}();$(document).ready(function(){selectnav('menu-main-nav');selectnav('menu-main-nav');});
$("#LinkList94").each(function () {
var k = "<ul id='menu-main-nav'><li><ul class='sub-menu'>";
$("#LinkList94 li").each(function () {
var a = $(this).text(),
o = a.substr(0, 1),
p = a.substr(1);
"_" == o ? (o = $(this).find("a").attr("href"), k += '<li><a href="' + o + '">' + p + "</a></li>") : (o = $(this).find("a").attr("href"), k += '</ul></li><li><a href="' + o + '">' + a + "</a><ul class='sub-menu'>")
});
k += "</ul></li></ul>";
$(this).html(k);
$("#LinkList94 ul").each(function () {
var k = $(this);
if (k.html().replace(/\s| /g, "").length == 0) k.remove()
});
$("#LinkList94 li").each(function () {
var k = $(this);
if (k.html().replace(/\s| /g, "").length == 0) k.remove()
})
});
$(document).ready(function ($) {
$("#menu").show();
$("ul.sub-menu").parent("li").addClass("has-children");
$('#search-icon').on('click', function () {
$('#nav-search').slideToggle(0)
});
//]]>
</script>
3. Copas kode CSS Menu Responsive berikut ini di atas kode ]]></b:skin>
#menu{display:none} |
4. Copas kode HTML Menu Responsive berikut ini di bawah kode </header> atau setelah kode header blog Anda.
<!-- Main Menu -->
<nav id='main-nav'>
<div class='row'>
<li class='li-home'><a expr:href='data:blog.homepageUrl'>Home</a></li>
<b:section id='menu' maxwidgets='1' name='Main Menu' showaddelement='yes'>
<b:widget id='LinkList94' locked='true' title='Main Menu' type='LinkList' version='1'>
<b:includable id='main'>
<div class='widget-content'>
<ul itemscope='' itemtype='http://schema.org/SiteNavigationElement'>
<b:loop values='data:links' var='link'>
<li itemprop='name'><a expr:href='data:link.target' itemprop='url'><data:link.name/></a></li>
</b:loop>
</ul>
</div>
</b:includable>
</b:widget>
</b:section>
<span id='search-icon'><i class='fa fa-search'/></span>
<div id='nav-search'>
<form action='/search/max-results=7' id='searchform' method='get'>
<input id='s' name='q' placeholder='Type and hit enter...' type='text'/>
</form>
</div>
</div>
</nav>
<!-- Main Menu (end) -->
<div class='clear'/>
Kode LAYOUT
Simpan di atas kode ]]></b:skin> atau dijajaran kode body#layout yang sudah ada.
body#layout #main-nav{height:auto;min-height:87px;overflow:hidden;padding-bottom:1px}
body#layout #main-nav .section{display:block;background-color:#3598db;border-color:#2980b9}
body#layout #main-nav .section h4{padding-bottom:3px;color:#fff}
body#layout #main-nav .section .widget-content{border-color:#fff}
body#layout li.li-home{display:none}
body#layout #main-nav .row{height:auto}
Klik Layout/Tata Letak untuk memasukkan daftar menu/link menu menggunakan Link List Widget yang sudah ada.
Demikian Cara Memasang Menu Responsive Dropdown + Kotak Pencarian Menggunakan Selectnav Javascript. Good Luck & Happy Blogging! (www.contohblog.com).
Sumber
Previous
« Prev Post
« Prev Post
Next
Next Post »
Next Post »
No comments on Cara Memasang Menu Responsive Dropdown + Kotak Pencarian Menggunakan Selectnav Javascript
Post a Comment