myMenu version 1.0 build 8
这个build中,增加了一些东西,随便看看吧
(function ($) {
// load css
$('head').append('<link href=\"http://www.nyinfo.ha.cn/digital/skin/100kind.css\" rel=\"stylesheet\" type=\"text/css\" />');
// plugin start
$.fn.myMenu = function (menus) {
return this.each(function () {
var outer = '<div class=\"channel-nav\"><ul>[c]</ul></div>';
var inner = '<li><a [target] [href] >[text]</a></li>';
var temp = '', text = '';
for (var m in menus) {
temp = inner.replace('[text]', menus[m][0]);
temp = menus[m][1] == '' ? temp.replace('[href]', menus[m][1]) : temp.replace('[href]', 'href=\"' + menus[m][1] + '\"');
temp = menus[m][2] == '' ? temp.replace('[target]', menus[m][2]) : temp.replace('[target]', 'target=\"' + menus[m][2] + '\"');
text += temp;
}
outer = outer.replace('[c]', text);
$(this).append(outer);
});
}
})(jQuery);
使用:
$(function () {
var menus = [
['首页', '/digital/list/318767104.html', '_blank'],
['首页', '/digital/list/318767104.html', '_blank'],
['首页', '/digital/list/318767104.html', '_blank']
];
$("body").myMenu(menus);
});

浙公网安备 33010602011771号