I have a quick and easy question. How can I check if an element is in the DOM or not?
For example, how can I check if <p id="does_i_really_exist_or">this is just matrix</p>
<p id="does_i_really_exist_or">this is just matrix</p>
if ( $("#does_i_really_exist_or").length ) { //-- It does exist. }
if ($("#does_i_really_exist_or").length > 0) { // do something }
there are three different ways:
if ($("#does_i_really_exist_or").length > 0) { // do something } if ($("#does_i_really_exist_or").size() > 0) { // do something } if ($("#does_i_really_exist_or")[0]) { // do something }