There is such a script:

var wpcomment = document.getElementById('post_new_txt'); wpcomment.onkeyup = wpcomment.onkeypress = function(){ document.getElementById('flash').innerHTML = ('Пишет вам сообщение'); } 

When entering text, it shows "Writes you a message," and if you delete everything, it still shows. It is necessary to hide this inscription if a person does not write. How to implement it?

  • one
    there is no jquery here. return from the event handler and assign an empty string in the innerHTML of the flash element if this.value==='' - zb '
  • @eicto Thank you so much. - andreykartavtsev

2 answers 2

response from comment:

return from the event handler and assign the empty string in the innerHTML of the flash element if this.value==='' .

    Add a keyup check to your code:

     wpcomment.onkeyup = function() { document.getElementById("flash").innerHTML = ""; } 

    Thus, at the keyup event keyup we clear document.getElementById("flash") . Everything is very simple.