Here is my code:
hasAttr = new function(tag, attrName) {
return (tag.attrName)
}
Will this code work? I can't test it now because I cannot acces jsfiddle and jsbin but Down For Everyone or Just Me? says something else.
Example usage:
JavaScript:
alert(hasAttr("div", "id"))
HTML:
<div id="header"></div>
Expected:
(In alert box)
true
OK
Can someone test it for me?
If it doesn't work, how should I code it?
I want hasAttr
to return true
or false
.
I will be open to code optimization, cleaner code etc.
Thanks in advance!
hasAttr("div", "id")
You are sending a string "div" and you are treating it like an object in your function. Something is wrong! \$\endgroup\$