请教JS封装的一个问题?
代码如下:
///js部分$(document).ready(function(){
$('.boxgrid.slidedown').hover(function(){
$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:500});
}, function() {
$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:500});
});
});///HTMl部分<div class="boxgrid captionfull"> <img src="images/jareck.jpg"/>
<div class="cover boxcaption">
<h3>Jarek Kubicki</h3>
<p>Artist<br/>
<a href="####" target="_BLANK">More Work</a></p>
</div>
</div>
对于单一页面但一层好用,但如果对于多个层则需要分别写出对应js代码。 目的是:现想通过js封装,将上面的代码封装成方法,方便灵活使用。 请问 js封装我要怎么封装。小弟没接触过。
代码如下:
///js部分$(document).ready(function(){
$('.boxgrid.slidedown').hover(function(){
$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:500});
}, function() {
$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:500});
});
});///HTMl部分<div class="boxgrid captionfull"> <img src="images/jareck.jpg"/>
<div class="cover boxcaption">
<h3>Jarek Kubicki</h3>
<p>Artist<br/>
<a href="####" target="_BLANK">More Work</a></p>
</div>
</div>
对于单一页面但一层好用,但如果对于多个层则需要分别写出对应js代码。 目的是:现想通过js封装,将上面的代码封装成方法,方便灵活使用。 请问 js封装我要怎么封装。小弟没接触过。
如果需要样式再添加其他的class
css选择器 可以并列选择的