Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well there are a lot of things that could be optimized imho.</p> <p>A short list on the javascript:</p> <ul> <li>Remove the first 4 call to <code>hide()</code>, it's better to just add the following css <code>#children-cross,.partner-info,.children-info,#partner-cross{display:none;}</code> in your css declaration.</li> <li>Both click options ave a lot of thing in common, you could factorize them</li> <li>Inside each click the inside of the if and the else have also a lot in common, and could be grouped as well.</li> </ul> <p>If you don't want to search how to do that by yourself, here is an example of some JavaScript that will do the same (there may be some stuff to improve/change in there but it's just to get an idea) :</p> <pre><code>$(document).ready(function() { $('.add-partner').click(function(){ handleClick("partner",10,18); }); $('.add-children').click(function(){ handleClick("children",0.5,0.5); }); }); function add(a,b){ return a+b; } function minus(a,b){ return a-b; } function handleClick(keyword,plan1Diff, plan2Diff){ var condition = $('.'+keyword+'-info').css('display') === 'block'; var newText = (condition) ? "add "+keyword:"for your "+keyword; var func =(condition) ? minus : add; $('.'+keyword+'-info').toggle(); $('#'+keyword+'-cross').toggle(); $('#add-'+keyword).text(newText); $('#'+keyword+'-li').toggleClass('selected'); $('#Lvl01').text(func(parseFloat($('#Lvl01').text()),plan1Diff).toFixed(2)); $('#Lvl02').text(func(parseFloat($('#Lvl02').text()),plan2Diff).toFixed(2)); } </code></pre>
    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. 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