If div doesn't have img tag, add a "no image" img to div (Javascript or Jquery) -


I am trying to include an IVG tag in a div element if the div element does not already have an IMG tag What is the best way to use? I want to see the answers in javascript and jquery so that it helps me learn but one is ok either.

I have used some jquery efforts. (Not) and .empty () But I think I am not thinking it correctly.

Try this:

  if ($ ('$ your_div' ). ('Img'). Length == 0) {$ ('# your_div'). Prepaid ('& lt; img src = "img / your_image Jpg" / & gt;'); }   



Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -