jquery 按鈕切換外掛程式

2022-08-29 15:24:37 字數 3180 閱讀 5400

樣式: 

點選第二個按鈕,彈出**函式。然後改變顏色。

//**函式

function

callback(dom)

//基於name取dom元素$('

[name=s_marketenable]

').switchbutton();

script

>

body

>

html

>

;(function

($) ;

var opts =$.extend({},defaults,options);

var _self = this

;

var swtichbtn =

$('#' + id).on('click',function

() )})}

else

) }

},clickevent:

function

(domele)

else

},bindevent:

function

(dom)

else

},on:

function

(dom) ,

off:

function

(dom)

}swtichbtn.init(opts);

}})(jquery);

[class|=switch].switch:before .switch-on .switch-on:before.switch-off:before.switch-off
如果是通過ajax渲染資料的,也是可以使用。但得在渲染完成後才能呼叫

採用 mock.js模擬資料,然後用ajax請求渲染到form表單裡面

doctype html

>

<

html

lang

="en"

>

<

head

>

<

meta

charset

="utf-8"

>

<

title

>title

title

>

<

link

rel="stylesheet"

href

="t-switch.css"

>

head

>

<

body

>

<

form

>

form

>

<

script

src="jquery.min.js"

>

script

>

<

script

src="switch-button.js"

>

script

>

<

script

src="mock.js"

>

script

>

<

script

>

varhtml =''

; mock.mock(

'/test/getdata',]

})$.ajax().done(

function

(data,status,jqxhr) )

$('form

').html(html);

//資料渲染完呼叫

//$('form').children('.switch').switchbutton();$('

.switch

').switchbutton();

});//**函式

function

callback(dom)

script

>

body

>

html

>

按鈕外掛程式和按鈕狀態切換

按鈕外掛程式 1.data loading text 正在登入.按鈕單擊後不能點選,按鈕顏色變淺並且 文字為 正在登入.2000秒後恢復正常 繫結事件 定時器 id button loading window.settimeout function 2000 2.data complete text...

jquery 封裝頁面切換外掛程式

立即執行函式封閉作用域,實現元件化開發 fn.extend 擴充套件jquery外掛程式內容 建構函式儲存例項化引數 function 建立外掛程式dom結構 page.prototype.fillhtml function 繫結翻頁事件 page.prototype.bindevent funct...

封裝jQuery外掛程式實現TAB切換

先上效果圖 直接上 index.html doctype html html lang en head meta charset utf 8 title demo title script src jquery.js script script src tab.js script style tab...