jQuery.fn.extend () metode
contoh
Tambahkan dua metode untuk prototipe jQuery ($ .fn)
<Label> <input type = "checkbox" name = "foo"> Foo < / label>
<Label> <input type = "checkbox" name = "bar"> Bar < / label>
<Script> $ (function () {$. Fn. Memperpanjang ({
periksa: function () {
kembali ini. masing-masing (function () {
. Ini diperiksa = true;}) ;}, hapus centang: function () {
kembali ini. masing-masing (function () {
. Ini diperiksa = false;}) ;}
}); // Gunakan .check baru dibuat () metode $ ( "Input [type = 'checkbox' ]" ) Periksa () ;.}) </ Script>
Coba »
Definisi dan Penggunaan
$ .fn.extend () Fungsi jQuery memperpanjang satu atau lebih contoh properti dan metode (terutama digunakan untuk metode ekstensi).
Tip: jQuery.fn adalah jQuery objek prototipe, yang memperpanjang () metode yang digunakan untuk menambah properti baru dan metode untuk jQuery prototipe. Metode ini dapat dipanggil jQuery contoh objek.
tatabahasa
$.fn.extend( object )
参数 | 描述 |
---|---|
object | Object类型 指定的对象,用来合并到jQuery的原型对象上。 |