We would like to know how to check element existance.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- w ww . j a v a 2s . c o m-->
if(document.getElementById('slider')){
console.log("Id slider exist");
}
if(document.getElementsByClassName("someClass")[0]){
console.log("Class exist");
}
}
</script>
</head>
<body>
<div id="slider"></div>
<div class="someClass"></div>
</body>
</html>
The code above is rendered as follows: