Created
January 24, 2012 22:09
-
-
Save tncbbthositg/1673028 to your computer and use it in GitHub Desktop.
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
// basic example | |
$('span').filter(function() { | |
return this.innerHTML.match(/\b(fire|aqua|elec|wood)\b/gi); | |
}).css("border", "1px solid red"); | |
// styling each individual word | |
var fire = "<span style='border: 3px solid red;'>fire</span>"; | |
var aqua = "<span style='border: 3px solid blue;'>aqua</span>"; | |
var elec = "<span style='border: 3px solid gray;'>elec</span>"; | |
var wood = "<span style='border: 3px solid brown;'>wood</span>"; | |
$('span').filter(function() { | |
return this.innerHTML.match(/\b(fire|aqua|elec|wood)\b/gi); | |
}).each(function(i, o) { | |
o.innerHTML = o.innerHTML.replace("fire", fire) | |
.replace("aqua", aqua) | |
.replace("elec", elec) | |
.replace("wood", wood); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment