论GBIN1.com底部今日推荐功能开发原理

本文展示了一个使用HTML5和JavaScript实现的动态消息推荐模块。该模块通过加载外部HTML文件来更新推荐内容,并利用淡入淡出效果及宽度变化增强用户体验。文章详细介绍了如何用jQuery选择器操作DOM元素,实现元素的动态加载、链接地址修正等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看效果:http://www.gbin1.com/technology/html/20120328crazyhtml5js/index.html

// html
<div id="msgwrap">
<span id="title">今日推荐</span><a id="msgclose" href="#">&nbsp;</a>
<div id="latest"></div>
</div>

// script

// Today's recommendation
var msgclose = $( '#msgclose');
var msg = $( '#msgwrap');
var latest = $( '#latest');
latest. load( '/portfolio/lastest.html .includetitle', function() {
latest. find( '.includetitle'). hide();
var aobjs = latest. find( 'a');
aobjs. each( function(){
var srcval = $( this). attr( 'href'). replace( '..', '');
$( this). attr( 'href', srcval);
});
});
setTimeout( function(){ msgclose. fadeIn(); msgclose. click();}, 10* 1000);
msgclose. toggle( function() {
msg. stop(). animate({ width: '+=250', bottom: '+=20px'}, 500, function() {
latest. find( '.includetitle'). eq( getRan( 4)). fadeIn();
});
$( '#msgclose'). css({ 'background-image': 'url("/gbin1/themes/gbin1_3column/images/x_icon.png")'});
},
function() {
$( '#latest'). find( '.includetitle'). hide();
msg. stop(). animate({ width: '-=250', bottom: '-=20px'}, 500);
$( '#msgclose'). css({ 'background-image': 'url("/gbin1/themes/gbin1_3column/images/icon_plus.png")'});
});


function getRan( n){
return Math. floor( Math. random()* n+ 1);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值