JSFiddle - React, Tailwind, and code Playground
by MegaScience
HTML
<h1>Override a jQuery Method</h1>
<p>
<a>Remove Me 1</a>
<a>Remove Me 2</a>
<a>Remove Me 3</a>
</p>
JavaScript
// http://www.bennadel.com/blog/1624-ask-ben-overriding-core-jquery-methods.htm
// Create a closure so that we can define intermediary
// method pointers that don't collide with other items
// in the global name space.
(function() {
// Store a reference to the original remove method.
var originalRemoveMethod = jQuery.fn.remove;
// Define overriding method.
jQuery.fn.remove = function() {
// Log the fact that we are calling our override.
console.log("Override method");
// Execute the original method.
originalRemoveMethod.apply(this, arguments);
}
})();
// When DOM is ready, initialize.
$(function() {
$("a")
.attr("href", "javascript:void( 0 )")
.click(
function() {
// Remove the target link.
$(this).remove();
// Cancel default event.
return (false);
}
);
});
// http://stackoverflow.com/questions/9134686/adding-code-to-a-javascript-function-programatically
/*(function() {
$("#top-rcg:not(.loaded)").waypoint(function() {
app.topRCG();
}, {
offset: '100%'
});
$(document).on('change', "#top-comics", function() {
var type = $(this).val();
app.topRCG(type);
});
$(document).on('click', ".rcg-lock", function() {
var $fa = $(this).find('.fa');
$fa.toggleClass('fa-unlock');
$fa.toggleClass('fa-lock');
$(this).toggleClass('primary');
return false;
});
$(document).on('click', ".rcg-remove", function() {
$(this).toggleClass('is-locked');
$("#generate-new-comic").click();
return false;
});
$(document).on('click', "#generate-new-comic", function() {
var is_random = ($('#rcg_random').val() == 'true');
var url = $(this).attr('href');
var params = ''
$(".rcg-remove").each(function() {
params += (params !== '') ? '&' : '?';
if ($(this).filter('.is-locked').length > 0) {
params += $(this).attr('data-index') + '=' + $(this).attr('data-panel');
} else {
params += 'promo=false';
...