(function ($) {
$.fn.myMenu3 = function(menus,index){
// menu div
var menu = document.createElement("div");
menu.setAttribute("id","menu");
// ul
var ul = document.createElement("ul");
for (var m in menus) {
var li = document.createElement("li");
// set default style
index = index == undefined ? 0 : index;
if (m == index) {
li.setAttribute("class","menu-current");
}
var a = document.createElement("a");
var span = document.createElement("span");
$(span).text(menus[m][0]);
a.setAttribute("href","http://");
a.appendChild(span);
li.appendChild(a);
ul.appendChild(li);
}
menu.appendChild(ul);
document.body.appendChild(menu);
return this;
}
})(jQuery);
$(function () {
$("body").myMenu3([["首页", "http://"], ["首页", "http://"], ["首页", "http://"]]);
});