Check if innerhtml is empty. My code is shown with comments below.