npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jclass.js

v1.0.13

Published

一个小巧的javascript方法类库

Readme

jClass

一个小巧的javascript方法类库,并且提供部分动画交互效果。

##Selector

DOM选择器

使用方法与jQuery的基本一致,但只提供部分API。 支持tagName, className, name, id, attribute, string 等方式选择或创建DOM对象。 支持链式表达,暂不支持只对子级进行查找模式(div > p默认子孙级都查找,查找name时请使用识别码@,比如:@username

  • each() 遍历结果
  • addClass() 添加样式
  • removeClass() 删除样式
  • hasClass() 包含样式
  • data() DataSet
  • attr() 属性
  • removeAttr() 删除属性
  • remove() 移除元素
  • after() 在之后添加
  • afterTo() 添加到之后
  • before() 在之前添加
  • beforeTo() 添加到之前
  • append() 内部添加子元素
  • appendTo() 作为子元素添加到
  • clone() 克隆
  • html() 内部HTML
  • outerHtml() 外部HTML
  • text() 文本内容
  • val()
  • eq() 索引
  • first() 第一个
  • last() 最后一个
  • prev() 前一个
  • next() 下一个
  • find() 查找下级元素
  • css() CSS属性、设置
  • width() 宽度
  • height() 高度
  • innerWidth() 内部宽度
  • innerHeight() 内部高度
  • alpha() 透明度
  • show() 显示
  • hide() 隐藏

  • on() 事件绑定
  • fade() 淡入淡出
  • shake() 震动
  • animateShape() 形状动画
  • get() 坐标值top, left, right, bottom
  • serialize() 序例化表单数据
  • checkbox() 选项框操作

以上API的使用与jQuery的使用基本一致,支持链式操作。部分如outerHtml(); alpha()等是jClass自有的API。

var $ = jClass;
$('#open').append($('div p.test').clone().attr('title', 'this is clone.'));
$('a').on('click', function(){
	$(this).shake(3); // 重复3次的默认偏移震动
	return false;
});

##Extend

扩展方法

jClass提供扩展方法用于一些日常的效果实现

  • load() 页面内容加载完成
  • domReady() 页面结构加载完成
  • addEvent() 添加事件
  • delEvent() 移除事件
  • isWho() 浏览器检测
  • colorToRgb() RGB颜色值
  • colorToHex() 十六进制颜色值
  • listMove() 多选下拉项转换
  • getHTML() HTML文本内某节点的HTML
  • cookie Cookies
  • stopBubble() 阻止冒泡
$.load(function(){
	if ($.isWho('ie')) {
		$.cookie.set('isIE', 'true', 30);
	}
});

##Ajax

AJAX请求

方法执行后返回XHR对象,可将此对象赋值给变量后,执行abort()操作。 本方法提供AJAX重发功能,可在触发error回调时执行retry()方法,重新执行AJAX请求,重试次数由配置retryCount指定,默认为3次。 注意本方法只提供success, error的回调,与jQuery支持的回调方法略有不同,并且不支持$.get(), $.post()等方法。

var xhr = $.ajax({
	url: 'http://www.simple.com/simple.php',
	method: 'POST',
	dataType: 'JSON',
	data: {
		user: 'Angus',
		age: 28,
		list: [1, 2, 3, 4]
	},
	success: function (jData, xhr){
		// success callback
		// this === jConfig
	},
	error: function (nStatus) {
		// error callback
		// this.retry();
	}
});

##Author © AngusYoung

E-mail [email protected]

Home (http://mrxcool.com)