jQuery Pass input attribute to a function and check if it exist
<p>I'm trying to check if an attribute exists on an input element. I created a hasAttr plugin as you see below to check if attr is undefined and false. Everything appears to be written correctly, but I'm not getting any response or errors.</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;form id="form"&gt;
    &lt;div&gt;&lt;input type="text" /&gt;&lt;/div&gt;
    &lt;div class="selected"&gt;&lt;input type="text" /&gt;&lt;/div&gt;
    &lt;div&gt;&lt;input type="text" /&gt;&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p><strong>jQuery hasAttr plugin</strong></p>

<pre><code>$.fn.hasAttr = function(name) {
    return this.attr(name) !== undefined &amp;&amp; this.attr(name) !== false;
};
</code></pre>

<p><strong>Function for passing attr name</strong> If attr exist then set value abc else alert false</p>

<pre><code>function formeditvalues(attr) {
    if ($('#form').find('.selected input').hasAttr(attr)) {
        $('#form'.find('.selected input').val('abc');
    } else {
        alert('false');
    }
}
</code></pre>

<p><strong>Calling the function gives no response.</strong> </p>

<pre><code>formeditvalues('type');
</code></pre>

<p>Check jsfiddle <a href="http://jsfiddle.net/KPczs/1/" rel="nofollow">http://jsfiddle.net/KPczs/1/</a></p>
