Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To bind all of them with access to <code>$(this)</code>, use <a href="http://api.jquery.com/each/" rel="nofollow noreferrer"><code>.each()</code></a>, like this:</p> <pre><code>$('textarea[name*=quote]').each(function() { $(this).limit('10',$(this).closest('form').find('span[name*=qc]')); }); </code></pre> <p>If you want <a href="http://api.jquery.com/live/" rel="nofollow noreferrer"><code>.live()</code></a>-like functionality on the second part, you need to either use <a href="http://plugins.jquery.com/project/livequery/" rel="nofollow noreferrer"><code>.livequery()</code></a>, like this:</p> <pre><code>$('textarea[name*=quote]').livequery(function() { $(this).limit('10',$(this).closest('form').find('span[name*=qc]')); }); </code></pre> <p>Or alternatively, bind them like the first example and also bind when loading new elements, e.g. if you're using <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow noreferrer"><code>$.ajax()</code></a>, it would look like this:</p> <pre><code>$.ajax({ url: blah.html success: function(data) { //do something with data $('textarea[name*=quote]', data).each(function() { $(this).limit('10',$(this).closest('form').find('span[name*=qc]')); }); } }); </code></pre> <p>The key here is <code>, data</code>, <a href="http://api.jquery.com/jQuery/" rel="nofollow noreferrer">it provides a context to search in</a>, so this is only executing on elements found in the returned data. You can also wrap this in a function to prevent duplication of code, like this:</p> <pre><code>function bindStuff(context) { $('textarea[name*=quote]', context || document).each(function() { $(this).limit('10',$(this).closest('form').find('span[name*=qc]')); }); } </code></pre> <p>In <code>document.ready</code>, call <code>bindStuff(document)</code>, in <code>$.ajax</code>, you'd call <code>bindStuff(data)</code>.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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