Не, по js у меня есть курсы. Хочу именно по библиотеке jQuery пройти чтобы бегло рассмотреть возможности. Понятно, что дока есть, но после курса в нее вникать будет проще и приятнее чем с нуля.
You can write your library knowing the language. Here is an example.
window.$ = (selector) => {
this.e = document.querySelectorAll(selector),
this.addClass = function(className){
for(const item of this.e){
item.classList.add(className)
}
return this;
},
this.removeClass = function(className){
for(const item of this.e){
item.classList.remove(className)
}
return this;
},
this.toggleClass = function(className){
for(const item of this.e){
Array.from(item.classList).includes(className)?item.classList.remove(className):item.classList.add(className);
}
return this;
}
return this;
};
console.log(
$('.testSelector').addClass('test')
,$('.testSelector').removeClass('test')
,$('.testSelector').toggleClass('test')
);