Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node' code example

Example 1: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'

// check if divId contains the word 'word' in innertext 

if (document.getElementById('divId').innerHTML.indexOf("word") != -1) { 
 // do something
}

Example 2: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'

// check if divId contains the word 'word' in innertext 

if (document.getElementById('divId').innerHTML.indexOf("word") != -1) { 
 // do something
}

Tags:

Misc Example