I am trying to add some form elements dynamically via Ajax with jQuery. I want to make sure that I don\'t create the same element twice, so I only want to add it if it hasn\
if ID is available - You can use getElementById()
ID
getElementById()
var element = document.getElementById('elementId'); if (typeof(element) != 'undefined' && element != null) { // exists. }
OR Try with Jquery -
if ($(document).find(yourElement).length == 0) { // -- Not Exist }