myMenu version 1.0 build 3

(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://"]]);
});
posted @ 2012-02-01 17:23  M80sic  阅读(119)  评论(0)    收藏  举报