jQuery filter selector, is this right?
- by fire
It seems to work ok but I don't know if this can be impoved on or not.
I want to select any HTML tag that has a class of edit-text-NUM or edit-html-NUM and change the color of it. Here is what I am using...
jQuery(document).ready(function(){
jQuery('*')
.filter(function() {
return this.className.match(/edit-(text|html)-\d/);
})
.css({
'color': '#ff0000'
});
});
Does that look ok and is the regex ok?
*edit: Also is this efficient? I am aware that using jQuery('*') might be a bit of a hog if it's a large page. It only has to work from <body> down so maybe it could be changed?