Forum Moderators: open
I'm working on a script that performs some operations on a page element with an id='example1'.
The problem is, it's an ajax page, and that element is not always there. So if it isn't on the page when the javascript runs, I get an error saying:
$(chkTracker[i][0]) has no properties
How can I check if that object does infact have properties? (something like php's is_set?)
Thanks!
Erik
<script type="text/javascript">
var realObj = {
"foo":"bar"
};
if( realObj )
{
alert( "realObj exists and has foo property: " + realObj["foo"] );
if( realObj["xyz"] )
{
// This will not happen
alert( "realObj has xyz" );
}
else
{
alert( "realObj does not have xyz property" );
}
}
</script>