TQuery

我的仿jq库

Fra 17.08.2015. Se den seneste versjonen.

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greasyfork.org/scripts/11045/68488/TQuery.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Forfatter
axetroy
Versjon
0.0.1.20150817124832
Lagd
18.07.2015
Oppdatert
17.08.2015
Size
40,5 kB
Lisens
I/T

TQuery

这是一个模拟jquery的轻量js库,(当然这里包含了很多的注释代码) 实现了jquery的大部分常用方法,包括选择符,事件绑定、处理,DOM操作,ajax等等 个人使用.....

兼容哪些浏览器

支持IE8+,chrome,firefox,opera等。IE8下,不定期删除某些兼容IE8下的部分。

如何添加插件?

1,源码中提供了一个extend方法,用于添加插件

格式是这样$().extend(fnName,fn); 参数:方法名,执行的方法 比如

$().extend('alert',function(){
  //do something
  alert( this );
    return this;  //返回TQuery对象,以便链式操作    $('p').css('width','500').alert().scoll()........
});

调用:

$().alert();  >>>>>>    TQuery{'elements':[],'vision':1.0,'length':0};

已经模拟的方法

选择器:

  • $()
  • find()
  • not()
  • flter()
  • add()
  • parents()
  • children()
  • prev()
  • next()
  • siblings()
  • slice()
  • eq()
  • get()

事件操作:

  • each()
  • trigger()
  • click()
  • bind()
  • unbind()
  • on()
  • one()
  • hover()
  • toggle()
  • mouseScroll()
  • matation()
  • ajax()

获取尺寸及设置:

  • width()
  • height()
  • top()
  • left()
  • viewWidth()
  • viewHeight()
  • style()
  • size()
  • scrollTop()
  • mouseScroll()

属性attr的设置

  • css()
  • animate()
  • stop()
  • attr()
  • hasClass()
  • removeClass()
  • addClass()
  • size()
  • scrollTop()
  • mouseScroll()

DOM节点的操作

  • insertAfter()
  • insertBefore()
  • empty()
  • remove()
  • html()
  • text()
  • addClass()
  • value()

其他方法

  • show()
  • hide()
  • scroll()