Uncaught TypeError: Cannot read property ‘nodeName’ of undefined magento2

Whenever we use Magento2 modal popup we may get below JS issue some times. This is might be because of the script is rendering before html.We can also restrict with checking some additional condition. As like below. Below is one of the condition, similarly we can validate other way also.
Console issue : Uncaught TypeError: Cannot read property ‘nodeName’ of undefined magento2
Solution for JS issue:

Check length of your div whether you declared div is available or not.
if (jQuery("#mymodalpopup").length != 0) { 
var pp = modal(options, $('#mymodalpopup')); 
jQuery('#mymodalpopup').modal('openModal');
}

Post by : Senthil.J

Smoking Injurious to Health !