Js determines whether there is a simple instance of the specified control on the page

  • 2020-03-30 02:13:51
  • OfStack

If (document. GetElementById (' show_pic)! = null) {document. GetElementById (' show_pic). SRC = this. The value; }

Show_pic is a picture control in the page, we first have to ensure that the control exists on the page, in order to operate on it, or JS will be wrong, so in this way to judge, I heard the net friend said, JS there is a function, can determine whether the object exists, but I did not find.


Related articles: