javascript - Using jQuery to achieve toggling, but I am missing something -


i trying make online calculator quadratic function different variable answers. doing kill curiousity using 1 id input , 4 functions control variety of toggling, getting input show it. when exact same thing b , change conditional id's around, acted , behaved a.

that's html portion, , using jquery toggle effects show not inputs.

<div class="left">     <ul class="nav"><h3>menu , solve tabs</h3>                 <li><a href="#" onclick="what();" id="togglesolve">toggle solve menu</a></li>         <li><a href="#" onclick="solvea();" id="solve">solve a</a></li>         <li><a href="#" onclick="solveb();" id="solve">solve b</a></li>         <li><a href="#" onclick="solvec();" id="solve">solve c</a></li>         <li><a href="#" onclick="solvex();" id="solve">solve x</a></li>         <li><a href="#" onclick="how();" id="togglehow">how solve</a></li>         <li><a href="mathapp_home.html">return home</a></li>     </ul> </div> <div class="content"><h3>this insert numbers.</h3>     <ul class="nav" name="quad"><p>quadratic formula:<br /> ax^2+bx+c=0</p><br />         <li><p>the formula solving is:<br /><spam id="formula"></spam></p></li>         <li><p id="a">input a:</p><input class="input" name="a" id="a"/></li>         <li><p id="b">input b:</p><input class="input" name="b" id="b"/></li>         <li><p id="c">input c:</p><input class="input" name="c" id="c"/></li>         <li><p id="x">input x:</p><input class="input" name="d" id="x"/></li>         <br />         <li><p>answer 1 variable<spam id="variableinputalpha"></spam><br /><spam id="answer"></spam></p></li>         <li><p>answer 2 variable<spam id="variableinputbeta"></spam><br /><spam id="answer2"></spam></p></li>     </ul> </div> 

here jquery:

$(document).ready(function(){     $("a#togglesolve").click(function what(){         $("a#solve").toggle(1000);     });     $("a#togglehow").click(function how(){         $("#howto").toggle(1000);     });     $("#solve").click(function solvea(){         $("#a, p#a").hide(1000)         $("#b, #c, #x, p#b, p#c, p#x").show(1000);     });     $("solve").click(function solveb(){         $("#b, p#b").hide(1000)         $("#a, #c, #x, p#a, p#c, p#x").show(1000);     }); }); 

is there way make array or make functions different selector? , let me know if asking wrong questions. still learning, , thank help!

as looked "undefined portion" have formulas on javascript , jquery, onclick functions jquery, appears "undefined" because specific function not defined in javascript, making appear of having errors. toggling jquery lot easier doing if else java, (this in own opinion, , entitled said opinions)

so sorted jquery , javascripts in each section if external files.

i use toggle hide p , "a" attributes , showed said attributes, find easier buttons instead of links such as:

<a href="#" onclick="blah();"></a> 

and made to

<button onclick="blah();"></button> 

this allows me go directly onclick event , not have href blank path can cause issues, such viruses etc. functions inert in javascript active in jquery.

if there different methods lemme know!


Comments