jQuery - check if element is exist (simplify version)

0 votes
377 views
added Nov 27, 2019 in jQuery by lcjr First Warrant Officer (11,760 points)
var propPlacement = $('body.page-content .news-body.content p:nth-child(4)'), 
    newsTopProp = $('body.page-content .featured-properties');
if(propPlacement) {
  newsTopProp.appendTo(propPlacement);
}

 

1 Response

0 votes
responded Feb 14, 2020 by lcjr First Warrant Officer (11,760 points)
if(yourElement.length){
    // do here
}

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...