在菜单中选定功能搜索引擎,在菜单描述中写入N个需要搜索关键词,用空格分隔
前台开发:
DIV:
<div class="keyword">$func_submenu(navi=Nav,para=Search,rows=16,memo=1)$</div>CSS:
#Nav .RowsTitle .Title{background:#005ea6;padding:25px 0;text-align:center;color:#fff}
#Nav .RowsTitle .Title .cn{font-size:20px;font-weight:700}
#Nav .RowsTitle .Title .en{text-transform:uppercase}
#Nav .RowsTitle .Title{font-size:16px;color:#fff}
.keyword .Descript{display:flex; flex-flow:row wrap;justify-content: space-between;padding-top:10px; padding-bottom: 20px;}
.keyword .Descript a{ padding:10px;cursor: pointer;}
JS:
$(function () {
var kw = $(".keyword").find(".Descript").html();
var k = kw.split(' ');
var kws = [];
var html = "";
for (var i = 0; i < k.length; i++) {
if (k != "") {
kws.push(k);
}
}
var rand = [];
rand = rnd(0, kws.length, 10);
for (var i = 0; i < rand.length; i++) {
html = html + "<a>" + kws[rand] + "</a>"
}
$(".keyword").find(".Descript").html(html).find("a").on("click", function () {
var kw = $(this).html();
$.send("",{kw:kw,so:1});
});
})
function rnd(min, max, count) {
var randoms = [];
while (true) {
var isExists = false;
var random = parseInt(min + (max - min) * (Math.random()))
for (var i = 0; i < randoms.length; i++) {
if (random === randoms) {
isExists = true;
break;
}
}
if (!isExists)
randoms.push(random);
if (randoms.length === count)
break;
}
return randoms;
}
JS需先载入jquery.js与hondy.js
案例:dymy
|