JS common functions are summarized in succession

Source: Internet
Author: User

The 1.each () method specifies the function to run for each matching element.

$.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);    }); // the attr () method sets or returns the property value of the selected element. 

2. Method callbacks

if ($.isfunction (LoadData)) loaddata (obj); $ (function () {        // initialize sliding div        Loadswitchbox ('. Boxwrap', LoadData,'#sub-framemain', ' tab_1.html ' );    });     // loading page Data     function LoadData () {    }

The 3:EQ () selector selects the element with the specified index value.

var default_btnwidth = $wraper. Find ('. Swichtxt '). EQ (0). Width ()
Oldindex = $wraper. Find ('. Cur '). Index (),

4. The animate () method executes a custom animation of the CSS property set.

This method changes the element from one state to another through CSS styles. CSS property values are changed gradually so that you can create animation effects.

$wraper. Find (". Switchbtn"). Animate ({' Left':'+='+ Distant +'px'}, Function () {$wraper. Find ('. Curtxt'). HTML (curtxt); $wraper. Find ("#switchBtn"). Width (elewidth); //Execute callback function                if($.isfunction (Fncallback)) fncallback (obj); });//sets the left offset of the switchbtn,

5.outerwidth (options)
Gets the outer width of the first matching element, including padding and borders by default.
This method is valid for both visible and hidden elements.
return value: Integer

    Wrapperwidth + = $(this). Outerwidth () + opadding;

The 6.offset () method returns or sets the offset (position) of the matching element relative to the document.

Distance from left of current span left position
var curbtn = $s _btn.offset (). Left;

JS common functions are summarized in succession

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.