一、概念
链式编程的概念: 当前对象调用完方法之后,会返回一个jQ对象,我们可以使用这个对象继续调用其他的方法
//可以直接.下去
$('css选择器').parents().find().val()
二、原理
// 原理: 返回调用者本身
let $ = {
css:function(){
console.log('css方法被执行了');
return this
},
on:function(){
console.log('on方法被执行了');
return this
},
siblings:function(){
console.log('siblings方法被执行了');
return this
}
}
$.css().on().siblings()