Created
April 20, 2017 03:34
-
-
Save gHashTag/e9ccb0b6d95ed3de59e9b037cd419fcd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<script> | |
(function($) { | |
$.fn.findReplace = function(options) { | |
var settings = $.extend({ | |
findText: null, | |
replaceText: "", | |
customClass: "", | |
completeCallback: null | |
}, options); | |
return this.each(function() { | |
var StringToFind = settings.findText; | |
var regExpression = new RegExp(StringToFind, "g"); | |
var replacement = "<span class='" + settings.customClass + "'>" + settings.replaceText + "</span>"; | |
$(this).html( | |
$(this).html().replace(regExpression, replacement) | |
); | |
if ($.isFunction(settings.completeCallback)) { | |
settings.completeCallback.call(this); | |
} | |
}); | |
}; | |
}(jQuery)); | |
$("a").findReplace({ | |
findText: "SEE", | |
replaceText: "Смотреть", | |
customClass: "div.healcode .trainer_list .trainer_teaches_link a", | |
completeCallback: function() { | |
$('.notification').text('Executed the plugin on all links').fadeOut(5000); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment