Simplify JavaScript

KC_Nikki

New Member
For my site I wrote a small piece of JavaScript that updates some elements in the browser when a button is clicked but this code seems to be redundant and inefficient. Is there any way to clean this up?\[code\]$(function () { $('#switch').click(function () { if ($('#header').text() == 'Sign In') { $('#header').text('Sign Up'); $('#switch').text('Sign In'); $('#submit').text('Sign Up'); $('#submit').attr('form', 'sign_up'); } else { $('#header').text('Sign In'); $('#switch').text('Sign Up'); $('#submit').text('Sign In'); $('#submit').attr('form', 'sign_in'); } });});\[/code\]
 
Back
Top