Answer the question
In order to leave comments, you need to log in
How to make your own jQuery from scratch?
How to call methods on a function in any order?
$(".class").parent().children().next().prev().hide().show() and so on.
I looked at jQuery sources and did not understand. I want to create my own library similar to jQuery for learning purposes. Thank you.
Answer the question
In order to leave comments, you need to log in
Each method must return a reference to your object
jsfiddle.net/96sa9d7e
How to call methods on a function in any order?
In each function, return an object.
Those. calling , takes an object and returns it at the end of the function, thus taking the return into an object, working with it, and returning it too, so that the next method down the chain can work further.
In the case of , etc., return the parent or child respectively $('.class').hide().show()
hide()
$('.class')
show()
hide()
parent()
children()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question