Changing attribute of dynamically generated tags with JQuery
<p>I have a requirement to rewrite <code>src</code> and/or <code>href</code> attribute of tags on a page using Jquery. I have tried this <a href="http://api.jquery.com/attr/" rel="nofollow">sample code.</a> It works for tags which are already in the html page, however for tags dynamically generated by Javascript it does not work. </p>

<p>Any solution for this kind of requirement that every time tags are generated like <code>img</code> tag I need to change it's attribute. </p>

<p>Sample Code:</p>

<pre><code>&lt;script&gt;
$("img").attr({ 
  src: "/images/hat.gif",
  title: "jQuery",
  alt: "jQuery Logo"
});
$("div").text($("img").attr("alt"));
&lt;/script&gt;
</code></pre>
