Fixing issue when trying to interrogate between id and name attribute

It's possible that $obj.attr('id') does not exist (in the case where we want to use the name attribute), thus an error will occur when trying to determine the length property.