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