Calling a jQuery method named in variable
<p>I have a JavaScript variable which contains the name of a jQuery method: <br></p>

<pre><code>var method = 'attr("src")';
</code></pre>

<p>How can I make it work like:</p>

<pre><code>console.log($('img').method)
</code></pre>

<p>I tried</p>

<pre><code>console.log($('img')[method]())
</code></pre>

<p>but it gives this error:</p>

<pre><code>Uncaught TypeError: Object [object Object] has no method 'attr("src")'
</code></pre>
