How can I tell if an element only contains a J character with JQuery?
4 answers
The tvanfosson code allows spaces on either side of the ยฃ sign, but the regexp can have a slight modification:
$('div:contains("£")').each( function() {
var text = $(this).html();
if (text && text.match(/^\s*£\s*$/)) {
$(this).addClass('pound');
}
});
notice the "^" and "$" indicating the beginning and end of the line.
0
source to share