Reputation: 16793
What is wrong with this code:
$('input[maxlength],textarea[maxlength]').not("[class^='tinymce']").each(function() {
I am trying to select:
<textarea>
s with an attr
maxlength
Upvotes: 0
Views: 103
Reputation: 6428
this code selects the textareas that don't have a class which begins with "tinymce".
$('input[maxlength],textarea[maxlength]').filter(function() {
if($(this).attr('class')) {
return null == $(this).attr('class').match(/\btinymce[a-z0-9_\-]*\b/i);
}
return true;
}).each(function() {
//your part
});
example: an element with class="another tinymceFOO"
is not selected (while the accepted answer would select it).
Upvotes: 0
Reputation: 77966
Does it have to start with tinymce
or just contain the class tinymce
?
$('input,textarea').filter(function(){
return(!$(this).hasClass('tinymce'));
}).filter(function(){
return($(this).attr('maxlength'));
})
Upvotes: 1