This should be simple, but I'm stupid so...
I want to do a simple conditional statement to see if the calendar has already been rendered within a div. Something like this:
if ( $('#calendar').fullCalendar() )
{
alert("calendar exists!!");
}
I want to do this so that I can remove, then re-init the calendar programatically. Basically, a 'reset' button.
Can someone please let me know the proper syntax to check if a fullCalendar object has been rendered?
Thank you in advance!!
I figured it out. jQuery has a .children()
selector. I was able to do a conditional statement on the .length
property of that selector to see if there was any content in the div:
if ( $('#calendar').children().length > 0 ) {
alert("calendar exists!!");
}
An alternative way to do this, without jQuery, is:
getElementById('calendar').hasChildNodes()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With