javascript - Checking innerHTML values if empty or not for Array of Object -
i trying check if below condition holds true:
var elemarray = document.getelementsbyclassname('customers'); for(var = 0; < elemarray.length; i++){ elemarray[i].id = i; var elem = document.getelementbyid(elemarray[i].id); var text = elem.innerhtml; text = text.tostring(); alert(text); if(text=="<br>"){ alert('bingo'); elem.style.visibility="hidden"; } }
in 1st alert can see values
1. <br>abc 2. <br>xyz
and empty values get:
1. <br> 2. <br>
so trying compare "bingo" not showing. missing?
looks have either special characters or spaces in content. remember == compares exact strings. i.e. '<br>'
, '<br> '
different.
here working jsfiddle , prints bingo fine. http://jsfiddle.net/1nxzxjdd/
some answers mention using indexof or contains method might not useful ops question because looks op interested in finding out values containing <br>
Comments
Post a Comment