JQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (a, e, h, b, d) { | |
b = e.createElement(h); | |
b.src = "//www.googleadservices.com/pagead/conversion.js"; b.async=1; | |
d = e.getElementsByTagName(h)[0]; | |
d.parentNode.insertBefore(b, d); | |
})(window, document, "script"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('click','a[href*="pop-"]',function(e){ | |
e.preventDefault(); | |
var id = $(this).attr('href').split('#pop-')[1]; | |
elementorProFrontend.modules.popup.showPopup({'id':id}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wrap = $(".navbar"); | |
$(document).scroll(function(e) { | |
if ($(this).scrollTop() > 247) | |
wrap.addClass("fixed"); | |
else | |
wrap.removeClass("fixed"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#content").load("somefile.html"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(function() { | |
$("#refresh").load(location.href+" #refresh>*",""); | |
}, 10000); // milliseconds to wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.str_replace = function(search, replacement) { | |
var target = this; | |
return target.replace(new RegExp(search, 'g'), replacement); | |
}; | |
string.str_replace('needle','replaced'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var maxheight = 0; | |
$("div.col").each(function(){ | |
if($(this).height() > maxheight) { maxheight = $(this).height(); } | |
}); | |
$("div.col").height(maxheight); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(location.hash){ | |
var e = document.getElementById(location.hash.substr(1)); | |
e.scrollIntoView(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("a[href='#top']").click(function() { | |
//$("#section").offset().top | |
$("html, body").animate({ scrollTop: 0 }, "slow"); | |
return false; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const updateDebounceText = debounce(() => { | |
incrementCount(debounceText) | |
}) | |
const updateThrottleText = throttle(() => { | |
incrementCount(throttleText) | |
}, 100) | |
function debounce(cb, delay = 1000) { | |
let timeout | |
return (...args) => { | |
clearTimeout(timeout) | |
timeout = setTimeout(() => { | |
cb(...args) | |
}, delay) | |
} | |
} | |
function throttle(cb, delay = 1000) { | |
let shouldWait = false | |
let waitingArgs | |
const timeoutFunc = () => { | |
if (waitingArgs == null) { | |
shouldWait = false | |
} else { | |
cb(...waitingArgs) | |
waitingArgs = null | |
setTimeout(timeoutFunc, delay) | |
} | |
} | |
return (...args) => { | |
if (shouldWait) { | |
waitingArgs = args | |
return | |
} | |
cb(...args) | |
shouldWait = true | |
setTimeout(timeoutFunc, delay) | |
} | |
} | |
document.addEventListener("mousemove", e => { | |
incrementCount(defaultText) | |
updateDebounceText() | |
updateThrottleText() | |
}) | |
function incrementCount(element) { | |
element.textContent = (parseInt(element.innerText) || 0) + 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment