码迷,mamicode.com
首页 > Web开发 > 详细

js常用函数陆续总结

时间:2014-11-11 18:27:17      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   sp   strong   数据   div   

1.each() 方法规定为每个匹配元素规定运行的函数。 

$.each(data,function(index,item){
  sb.append(item.answerNum); }

$(".switchBox").each(function() {
        var id = $(this).attr("id");
        var type = $(this).attr("typeId");
        createSlideDiv(id, type, fn);
    });
//attr() 方法设置或返回被选元素的属性值。

2.方法回调

if ($.isFunction(loadData)) loadData(obj);

$(function(){
        //初始化滑动div
        loadSwitchBox(.boxwrap,loadData,#sub-frameMain,tab_1.html);
    });
    //加载页面数据
    function loadData(){

    }

3 :eq() 选择器选取带有指定 index 值的元素。

var default_BtnWidth = $wraper.find(‘.swichTxt‘).eq(0).width() 
oldIndex = $wraper.find(‘.cur‘).index(),

4. animate() 方法执行 CSS 属性集的自定义动画。

该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的,这样就可以创建动画效果。

$wraper.find(".switchBtn").animate({
                left: += + distant + px
            }, function() {
                $wraper.find(.curTxt).html(curTxt);
                $wraper.find("#switchBtn").width(eleWidth);
                //执行回调函数
                if ($.isFunction(fnCallBack)) fnCallBack(obj);
            });
//设置switchBtn的左偏移,

5.outerWidth(options)
获取第一个匹配元素外部宽度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer

    wrapperWidth += $(this).outerWidth() + oPadding;

6.offset() 方法返回或设置匹配元素相对于文档的偏移(位置)。

//当前span左侧位置离左边的距离
var curBtn = $s_btn.offset().left;

 

 

 

js常用函数陆续总结

标签:style   blog   io   color   ar   sp   strong   数据   div   

原文地址:http://www.cnblogs.com/m7777/p/4089965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!