If I understand correctly, you're looking to see if the inner html is empty.
You should be able to tell if the content is blank using innerHTML
:
var x = document.getElementById("f1");
if (x && x.innerHTML.trim() == ""){
document.write('<img src="/wp-content/uploads/2021/01/airplane_off.png" style="width: 512px; height: 512px; margin: 1px;" />');
}
else{
document.write('<img src="/wp-content/uploads/2021/01/airplane_on.png" style="width: 512px; height: 512px; margin: 1px;" />');
}
Note that your example uses <td id="f1"><td>
. The tag is not being closed, which will cause issues if you have that in the page too.
The other thing to note is that td
needs to be in a proper table structure (meaning inside a tr
which needs to be inside a table
) otherwise you won't be able to target it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…