module(“Module B”);
test(“some other test”, function() {
// 指定多少个判断语句需要加入测试中.
expect(2);
equals(true, false, “failing test”);
equals(true, true, “passing test”);
});
英文原文:More jQuery and General Javascript Tips to Improve Your Code
翻译原文:http://blog.bingo929.com/jquery-javascript-tips-to-improve-code.html
// element- DOM元素
// index – 堆栈中当前遍历的索引值
// meta – 关于你的选择器的数据元
// stack – 用于遍历所有元素的堆栈
// 包含当前元素则返回true
// 不包含当前元素则返回false
};
// 自定义选择器的应用:
$(‘.someClasses:test’).doSomething();
//下面让我们来看看一个小例子,我们通过使用自定义选择器来锁定含有”rel”属性的元素集:
$.expr[‘:’].withRel = function(element){
var $this = $(element);
// 仅返回rel属性不为空的元素
return ($this.attr(‘rel’) != ”);
};
$(document).ready(function(){
// 自定义选择器的使用很简单,它和其他选择器一样,返回一个元素包装集
// 你可以为他使用格式方法,比如下面这样修改它的css样式
$(‘a:withRel’).css(‘background-color’, ‘green’);
});
<ul>
<li>
<a href=”#”>without rel</a>
</li>
<li>
<a rel=”somerel” href=”#”>with rel</a>
</li>
<li>
<a rel=”” href=”#”>without rel</a>
</li>
<li>
<a rel=”nofollow” href=”#”>a link with rel</a>










