Why Safari? Why? If innerHTML == ”

So I had an issue with the following very simple textarea onblur code.  Interestingly enough, it worked in IE and Firefox.  I just want the two textareas to be identical at the end of the day.

if (document.getElementById(’TopNotes’).innerHTML == ”) {
  document.getElementById(’TopNotes’).innerHTML = ‘Put notes here’;
}
else {
  document.getElementById(’BottomNotes’).innerHTML = document.getElementById(’TopNotes’).innerHTML;
}

Safari always ran the if, and never the else.  I changed to this and it worked like a charm.

var text = document.getElementById(’TopNotes’).innerHTML;
if (text == ”) {
  document.getElementById(’TopNotes’).innerHTML = ‘Put notes here’;
}
else {
  document.getElementById(’BottomNotes’).innerHTML = text;
}

 

Leave a comment

You must be logged in to post a comment.

 
This site hosted by bowlingball.com - Find the best deals on Bowling Balls, Bowling Bags, Bowling Shoes, and Bowling Accessories.