Skip to content

Instantly share code, notes, and snippets.

@carmichaelize
Created March 7, 2016 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carmichaelize/85ce5084bc21a4ccb740 to your computer and use it in GitHub Desktop.
Save carmichaelize/85ce5084bc21a4ccb740 to your computer and use it in GitHub Desktop.
// Here You can type your custom JavaScript...
jQuery.fn.highlight = function (str, className) {
var regex = new RegExp(str, "gi");
return this.each(function () {
$(this).contents().filter(function() {
return this.nodeType == 3 && regex.test(this.nodeValue);
}).replaceWith(function() {
return (this.nodeValue || "").replace(regex, function(match) {
return "<span class=\"" + className + "\">" + match + "</span>";
});
});
});
};
$(".list-card-title").highlight("As an", 'highlight');
$(".list-card-title").highlight("As a", 'highlight');
$(".list-card-title").highlight("I want", 'highlight');
$(".list-card-title").highlight("so that", 'highlight');
$( ".list-card-details" ).find( ".card-label-red" ).parent().parent().addClass('defect');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment