TQuery

我的仿jq库

Tính đến 10-12-2021. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/11045/996871/TQuery.js

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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!)

Tác giả
axetroy
Phiên bản
0.0.1.20150907023508
Đã tạo
18-07-2015
Đã cập nhật
10-12-2021
Kích thước
60 KB
Giấy phép
N/A

TQuery

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

用法我就不多说了,跟jquery差不多,而且目前也就我一个人用。

兼容哪些浏览器

支持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};

已经实现的方法(包括我jquery没有的)

选择器:

  • $(selectors)
  • .eq()
  • .first()
  • .last()
  • .not()
  • .filter()
  • .find()
  • .add()
  • .slice()
  • .end()
  • .has()
  • .visible()
  • .unvisible()

遍历操作:

  • .each()
  • .findParent()
  • .parent()
  • .parents()
  • .children()
  • .prev()
  • .prevAll()
  • .next()
  • .nextAll()
  • .siblings()

事件操作:

  • .ready()
  • .load()
  • .click()
  • .keydown()
  • .keyup()
  • .keypress()
  • .mousedown()
  • .mouseup()
  • .mouseenter()
  • .mouseleave()
  • .mousemove()
  • .mouseover()
  • .mouseout()
  • .hover()
  • .on()
  • .toggleClick()
  • .scroll()
  • .mouseScroll()
  • .mouseScrollUp()
  • .mouseScrollDown()
  • .bind()
  • .unbind()
  • .one()
  • .trigger()
  • .live()
  • .die()
  • .mutation()

获取尺寸及设置:

  • .width()
  • .height()
  • .innerWIdth()
  • .innerHeight()
  • .top()
  • .left()
  • .viewWidth()
  • .viewHeight()
  • .style()
  • .scrollTop()
  • .scrollHeight()
  • .scrollLeft()
  • .scrollWidth()
  • .size()
  • .offset()

属性attr的设置:

  • .prop()
  • .toggleProp()
  • .attr()
  • .toggleAttr()
  • .removeAttr()
  • .hasClass()
  • .addClass()
  • .removeClass()
  • .toggleClass()
  • .data()
  • .removeData()

CSS的操作设置:

  • .css()
  • .addStyle()
  • .removeStyle()

JS动画特效:

  • .animate()
  • .stop()
  • .show()
  • .hide()
  • .fadeToggle()
  • .fadeIn()
  • .fadeOut()
  • .fadeTo()
  • .scale()
  • .toggle()
  • .slideToggle()
  • .slideRight()
  • .slideLeft()
  • .slideDown()
  • .slideUp()
  • .scrollTo()
  • .scrollToggle()

DOM节点的操作:

  • .clone()
  • .append()
  • .appendChild()
  • .prepend()
  • .prependChild()
  • .after()
  • .before()
  • .remove()
  • .empty()
  • .html()
  • .text()
  • .val()

其他方法:

  • .proxy()
  • .delay()
  • .do()

转换:

  • .get()
  • .toArray()
  • .index()

工具集合:

  • $.type()
  • $.isNumber()
  • $.isString()
  • $.isFunction()
  • $.isArray()
  • $.isObject()
  • $.isDOM()
  • $.isWindow()
  • $.isUndefined()
  • $.ajax()
  • $.unique()
  • $.noop()
  • $.trim()
  • $.now()
  • $.reload()
  • $.toArray()
  • $.upper()
  • $.shuffleArray()
  • $.sizeof()
  • $.browser()
  • $.browser.webkit()
  • $.browser.msie()
  • $.browser.moz()
  • $.browser.opera()
  • $.merge()
  • $.map()
  • $.parseJSON()