Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

JS - if element exist or present

0 votes
51 views
added Jun 28, 2019 in Javascript by LC Marshal Captain (25,800 points)
edited Aug 8, 2019 by LC Marshal
var parExs = document.getElementById('parallax');

//in vanilla JS
if(parExs){
    console.log('Parallax present');
} else {
    console.log('Parallax not present');
}

 

1 Response

0 votes
responded Aug 8, 2019 by LC Marshal Captain (25,800 points)
var element = document.querySelector('.winbutton');
if(element){
  element.classList.remove('full', 'elem-center');
  element.classList.add('half', 'elem-left');
  var createElementFromHTML = function(b) {
    var a = document.createElement('div');
    a.innerHTML = b.trim();
    return a.firstChild
  };
  element.parentNode.insertBefore(createElementFromHTML('\x3ca href\x3d"https://lazacode.org/subscribe" class\x3d"elem-right  half"\x3eEmail Subscription\x3c/a\x3e'), element.nextSibling)
}

 

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