Note that there are some explanatory texts on larger screens.

plurals
  1. POStop jQuery from repeating, example attached
    primarykey
    data
    text
    <p>I have to attach a jQuery to an invoice. Sometimes I have to print multiple invoices as once in a batch. When this happens my exact same jQuery appears for every invoice and it runs each time creating extra elements I do not need. Is there a way to have a jQuery that appears more then once only run once when it is the last time it appears in the code? Thanks for any help.</p> <p>Example is below. I have previously posted this and everyone asked to see how I was doing it. I was not sure how to add the code to the post as it said it was too long. Thanks for all your help. You guys are awesome.</p> <pre><code>&lt;table width=180 border=0 cellpadding=0 cellspacing=0&gt; &lt;tr&gt; &lt;td class="barcode_needed"&gt;10133&lt;/td&gt; &lt;/tr&gt; &lt;!--This section of code is attached to every order so it repeats when each order prints, (this is a simplified version of the code, I need to make it only run the last time it shows up--&gt; &lt;link rel="stylesheet" type="text/css" href="http://barcode-coder.com/css/style.css?ft=1298939919" /&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-1.3.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-ui-1.7.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-barcode-last.min.js"&gt;&lt;/script&gt; &lt;script&gt; $('td.barcode_needed').append('&lt;div class="bcTarget"&gt;'); $('.bcTarget').each(function() { var $this = $(this); $this.barcode( 'G' + $this.closest('td.barcode_needed').text(), 'code128' ); }); &lt;/script&gt; &lt;!--End Repeating Code--&gt; &lt;tr&gt; &lt;td class="barcode_needed"&gt;20133&lt;/td&gt; &lt;/tr&gt; &lt;link rel="stylesheet" type="text/css" href="http://barcode-coder.com/css/style.css?ft=1298939919" /&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-1.3.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-ui-1.7.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-barcode-last.min.js"&gt;&lt;/script&gt; &lt;script&gt; $('td.barcode_needed').append('&lt;div class="bcTarget"&gt;'); $('.bcTarget').each(function() { var $this = $(this); $this.barcode( 'G' + $this.closest('td.barcode_needed').text(), 'code128' ); }); &lt;/script&gt; &lt;tr&gt; &lt;td class="barcode_needed"&gt;30133&lt;/td&gt; &lt;/tr&gt; &lt;link rel="stylesheet" type="text/css" href="http://barcode-coder.com/css/style.css?ft=1298939919" /&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-1.3.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-ui-1.7.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://barcode-coder.com/js/jquery-barcode-last.min.js"&gt;&lt;/script&gt; &lt;script&gt; $('td.barcode_needed').append('&lt;div class="bcTarget"&gt;'); $('.bcTarget').each(function() { var $this = $(this); $this.barcode( 'G' + $this.closest('td.barcode_needed').text(), 'code128' ); }); &lt;/script&gt; &lt;/table&gt; </code></pre>
    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