I have two textarea and one of them has id
attribute and other one doesn't has. Something like this:
<textarea> </textarea>
<textarea id = 'idname'> </textarea>
Now I need to select first textarea, How can I do that?
You could combine the :not()
pseudo-class and the [id]
attribute selector in order to negate elements with an id
attribute:
textarea:not([id]) {}
document.querySelectorAll('textarea:not([id])');
$('textarea:not([id])');
Basic Example:
textarea:not([id]) {
width: 100%;
}
<textarea></textarea>
<textarea id='idname'></textarea>