Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest not to mix up combining the event handlers that too of different selectors, instead just move generic functionality to a common function that can be called. This will help you maintain different event as it is ans any modification required in future on any of these handlers will make it easier with this approach rather than again splitting them out later.</p> <p>sometimes you don't want to make everything <code>DRY</code>.</p> <pre><code>$(function(){ //ready is not required if it is bound to document head $(document).on('change', '#selectContainer [id]', function () { prevClass = className; className = $("select").val(); &lt;&lt;&lt;&lt; DIFFERENT transformImage(className); // call the method to do the image processing } $(document).on('click', '.inter [class], .inter #back [id]', function () { prevClass = className; className = (this.id || this.className).substr(1); &lt;&lt;&lt;&lt; DIFFERENT transformImage(className);// call the method to do the image processing } }); //Move out your generic piece of functionality to another method. Put it out side of document.ready. function transformImage(className) { var back = '&lt;div id="back"&gt;&lt;div id="_'+ prevClass +'"&gt;&lt;/div&gt;&lt;/div&gt;'; link[prevClass] = original; original = link[className]; link[className] += back; $('.inter').fadeTo(250, 0.25, function () { $('.inter').html(link[className]); $('.inter').css({'background-image': 'url("' + className + '.png")'}); $('.inter').fadeTo(250, 1.00); }); } </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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