Skip to content

Instantly share code, notes, and snippets.

View shyamvkansagra's full-sized avatar

Shyam Kansagra shyamvkansagra

View GitHub Profile
@shyamvkansagra
shyamvkansagra / Javascript_equivalents_for_jQuery.md
Last active October 18, 2021 20:43
This document lists some easy to use utility type functions when you want to replace jQuery with javascript. Also it describes few commonly used selectors and their equivalent javascript code.

Here I have listed jQuery selectors, their meanings and their equivalent javascript code to replace. Also, when code gets repetitive, I had created some util functions too which we can simply call and use.

Check out util functions: To create some for your code, you can create a global variable (if needed) and add our custom methods in it. This saves repetition of the code and feels like you are writing a library functions which can be used from anywhere.

window.Utils = {}

Utils.insertBefore = function(elemStrToAttach, insertPlaceElem) {
  var elemToInsert = SwymUtils.createElement(elemStrToAttach);
<script type="text/javascript" src="YOUR_SCRIPT_URL"></script>
<script type="text/javascript">
var swymJSObject = {
pid: "YOUR_PID_VALUE"
};
window.swymJSCCLoad = function(){
if(!window._swat) {
console.log("swymJSCCLoad", "if");
(function (s, w, r, e, l, a, y) {