Will this test to check if an element has an attribute work?
To check if an HTML element has an attribute, you should use hasAttribute. If you have to support IE6 and IE7, check its existence using [name].

Given that, the implementation of hasAttr would be something like this:

hasAttr = function(tag, attrName) {
    return tag.hasAttribute ? tag.hasAttribute(attrName)
                            : tag[attrName] !== undefined;
}