<script type="text/javascript">$(document).ready(function(){if ($("#heading").attr("name"))alert('Look, this is showing because it\'s not undefined');elsealert('This would be called if it were undefined or is there but empty');});</script><h1 id="heading" name="bob">Welcome!</h1>
var attr = $(this).attr('name');
// For some browsers, `attr` is undefined; for others,// `attr` is false. Check for both.if (typeof attr !== 'undefined' && attr !== false) {// ...}