Skip to content Skip to sidebar Skip to footer

Converting Jquery(.each, .find,.next) To Javascript

I'm involved in converting the jquery codes to java script for a requirement. Example 1 : There are a few child elements with class name 'child_elems' inside a parent html div with

Solution 1:

You may use below for your work, but beware they might not work with all browsers. It is always safe to use jQuery if possible.

// jQuery -> JavaScript
.each  -> array.forEach(callback[, thisArg])
.find  -> document.querySelector(selectors), document.querySelectorAll(selectors);

Solution 2:

You can definitely do this if you must, jQuery is just a layer that sits on top of javascript. When you write jQuery, you're writing javascript.

If you really need to go down this route, it might be helpful to look at the jQuery source. James Padolsey made a really helpful tool for inspecting the various methods that jQuery provides. You can see the tool here: http://james.padolsey.com/jquery/#v=git&fn=jQuery.fn.next.

Keep in mind that the jQuery team has spent years getting their code to work efficiently and for multiple browsers. Please don't be surprised if your code fails across browsers.


Solution 3:


Post a Comment for "Converting Jquery(.each, .find,.next) To Javascript"