Problem:
How do you check if there is an attribute on an element in jQuery?
Solution:
var attribute = $('#productid').attr('name');
// For some browsers, 'attribute' is undefined; for othersĀ 'attribute' is false. Check for both.
if (typeof attribute !== typeof undefined && attribute !== false) {
// ...
}