JavaScript如何实现以下效果?

2025-05-13 09:25:48
推荐回答(3个)
回答(1):

//jQuery 1.7+


blog



$("body #blog").one({
mouseenter:function(e){
//  初始化字母
var me = $(this);
me.html(me.html().replace(/(.)/g,'$1'));
me.children().first().attr('href', '#');
}
}).on({
click: function(e) {
var me = $(this);
var f = me.children().first();
while (f.attr('href') + '' == 'undefined') {
f = f.next();
}
f.removeAttr('href');
f.next().attr('href', '#');
//到达最后一个字母,开始进行处理
if (!f.next().length) {
//清除多余的标签
me.html(me.html().replace(/<\/.*?><.*?>/g, ''));
me.find('a').attr('href', '
);
//移除click事件
$(this).off('click');
}
}
});

回答(2):

你是想点击B L O G四个字母组成一个博客的超链接?
字母就是一个链接,点击B时把B的链接remove掉,然后给L传一个href。。。依次类推。