jQuery扩展$.fn、$.extend jQery命名方法扩展 练习总结
2014-05-04 11:23
302 查看
<script>
$.fn.hello = function(){ //扩展jQuery实例的自定义方法,基于$.fn的jq方法扩展
this.click(function(){
alert('hello');
})
}
$('input').hello(); // 点击input正确出弹窗 'hello'
</script>
<script>
$.fn.extend({ //用extend扩展jQuery实例的自定义方法
hello:function(){
this.click(function(){
alert('hello');
})
}
})
$('input').hello(); // 点击input正确出弹窗 'hello'
</script>
<script>
$.fn.extend({ //extend扩展jq实例的 ‘属性’
hello:'hello',
})
var obj = new $; //创建以jq为构造原型的 实例obj
document.write(obj.hello) //打印字符串“hello“
</script>
<script>
$.extend({ //扩展jQuery这个全局对象的自定义方法
hello:function(){
$('input').click(function(){
alert('hello');
})
}
})
$.hello(); // 点击input正确出弹窗 'hello'
</script>
$.fn.hello = function(){ //扩展jQuery实例的自定义方法,基于$.fn的jq方法扩展
this.click(function(){
alert('hello');
})
}
$('input').hello(); // 点击input正确出弹窗 'hello'
</script>
<script>
$.fn.extend({ //用extend扩展jQuery实例的自定义方法
hello:function(){
this.click(function(){
alert('hello');
})
}
})
$('input').hello(); // 点击input正确出弹窗 'hello'
</script>
<script>
$.fn.extend({ //extend扩展jq实例的 ‘属性’
hello:'hello',
})
var obj = new $; //创建以jq为构造原型的 实例obj
document.write(obj.hello) //打印字符串“hello“
</script>
<script>
$.extend({ //扩展jQuery这个全局对象的自定义方法
hello:function(){
$('input').click(function(){
alert('hello');
})
}
})
$.hello(); // 点击input正确出弹窗 'hello'
</script>
相关文章推荐
- jquery中的ajax方法怎样通过JSONP进行远程调用
- JQuery A Brief Look
- jquery 判断元素可见性
- jquery mobile href超链接 单击显示error loading page
- 自己写了一个图片的马赛克消失效果(jQuery)
- 通过jQuery的attr修改onclick
- jQuery.extend 函数详解
- jquery easyui accordion 全部折叠问题
- Yii 日历选择的使用。 CJuiDatePicker ,其它他集成了 jquery 自带的日历控件
- JQuery EasyUI 数字格式化处理办法
- jQuery中的Ajax几种请求方式
- jquery 工程开发指南
- jQuery AJAX实例
- jquery 鼠标拖动排序Li或Table
- jquery的ajax同步和异步的理解及示例
- jQuery一些常用特效方法使用实例
- jquery 序列化表单进行提交笔记
- jquery中的ajax方法怎样通过JSONP进行远程调用
- 自己用jQuery写了一个图片的马赛克消失效果
- jquery实现的鼠标拖动排序Li或Table