Home  >  Article  >  Web Front-end  >  一个封装js代码-----展开收起效果示例_javascript技巧

一个封装js代码-----展开收起效果示例_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:30:181173browse

第一次靠自己完整的封装的小特效,有点小小的兴奋,和大家分享下,希望能对和我一样在探索的童鞋们有点帮助
js部分:

复制代码 代码如下:

var show_obj = function(obj,at,ob){
$(obj).bind('click', function(){
var showTxt = $(this).children(at);
//alert($(at).html());
//alert(sObj);
//alert();
//alert($(this).parent().children(p).html());
if(showTxt.html() == '+'){
showTxt.html('-')
}else{
showTxt.html('+')
}
$(this).parent().children(ob).slideToggle(300);
})
}

html 引用:
复制代码 代码如下:

$(function(){
show_obj('.slide_show','.slide_show a','.p-silde');
})
html 代码:


PS:记住引用jQuery的框架,兼容ie6以上,火狐,谷歌,ie6没有测试大家可以自己测试
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn