Created
March 7, 2016 13:43
-
-
Save carmichaelize/85ce5084bc21a4ccb740 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
// 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