Adi
Adi

Reputation: 4022

javascript (prototype) if element does not have attribute

in prototype I have this 'if' statement that works fine:

if(parentForm.hasAttribute('action')){
 console.log('hello world')
}

However, how do I turn this into a 'if parentForm DOES NOT have attribute action' statement?

Many thanks, Adi.

Upvotes: 0

Views: 167

Answers (1)

Matt
Matt

Reputation: 75317

Simply negate the conditional using the logical not operator;

if(!parentForm.hasAttribute('action')){
 console.log('hello world')
}

Upvotes: 1

Related Questions