Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery function problem
    primarykey
    data
    text
    <p>I have a problem with this Jquery function. The the simplifide code looks like:</p> <pre><code>$(document).ready(function(){ $(".brs").toggle(function() { var commid=$(this).attr('kid'); $('.comment'+commid).html('the new text - &lt;a href="javascript: void(0)" class="brs2" kid="'+ commid +'"&gt;click to change the text&lt;/a&gt;'); }, function () { var commid=$(this).attr('kid'); $('.comment'+commid).html('new text'); }); $(".brs2").click(function() { alert("test"); }); }); </code></pre> <p>HTML code:</p> <pre><code>&lt;div class="comment1"&gt;some text&lt;/div&gt; | &lt;a href="javascript: void(0)" class="brs" kid="1"&gt;test link&lt;/a&gt; </code></pre> <p>When the text changes in the div "comment1" the link that runs another function (class "brs2") does not work. What could be the problem?</p> <p>Thanks for all sugestions.</p> <p>EDIT:</p> <p>If the Jquery code looks like:</p> <pre><code>$(document).ready(function(){ $(".brs").toggle(function() { var commid=$(this).attr('kid'); $('.comment'+commid).html('the new text - &lt;a href="javascript: void(0)" class="brs" kid="'+ commid +'"&gt;click to change the text&lt;/a&gt;'); }, function () { var commid=$(this).attr('kid'); $('.comment'+commid).html('new text'); }); $(".brs2").click(function() { alert("test"); }); }); </code></pre> <p>And the HTML:</p> <pre><code>&lt;div class="comment1"&gt;some text&lt;/div&gt; | &lt;a href="javascript: void(0)" class="brs" kid="1"&gt;test link&lt;/a&gt; </code></pre> <p>I can't use live() to trigger the same toggle function with new link that appears in comment1 div?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload