jQuery
/*Check any ID exist or not*/
<div id='id1'></div>
<script type="text/javascript">
var id_exist = jQuery('#id1').length;
console.log(id_exist);
/*This will return 0 if ID not exist otherwise will get 1*/
</script>
<div id='id1'></div>
<script type="text/javascript">
var id_exist = jQuery('#id1').length;
console.log(id_exist);
/*This will return 0 if ID not exist otherwise will get 1*/
</script>
No comments:
Post a Comment