js常用函數陸續總結

來源:互聯網
上載者:User

標籤: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常用函數陸續總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.