jQuery: How to check if the javascript function exist
To check if the javascript function is exist, we can check using typeof(). See example below:
jQuery(document).ready(function() {
if(typeof $(".change-password").fancybox == 'function') {
$('.change-password').fancybox({
'width' : '60%',
'height' : 400,
'transitionIn' : 'fade',
'autoScale' : false,
'transitionOut' : 'fade',
'scrolling' : 'no',
'type' : 'iframe',
'href' : $(this).attr('href')
});
}
});
blog comments powered by Disqus