Given:
<meta name="someKindOfId" value="asdf" />
<meta http-equiv="Set-Cookie" content="cookie_value1" />
and
var meta1 = $('meta[name]').filter(function() {
console.log(this['name']);
});
var meta2 = $('meta[http-equiv]').filter(function() {
console.log(this['http-equiv']);
});
The first console.log outputs someKindOfId (correct).
But the second console.log outputs undefined twice, instead of Set-Cookie?
Why is this so?
Because
nameis a property of dom element object where arehttp-equivis not, it is an attribute value which is not copied as a property so tryAttributes like
name,id,valuehas corresponding property matches in the dom element reference, so those values will get copied to the properties of the dom element reference andthisinside the filter refers to the dom element