How can I simplify this jquery/javascript -
I am trying to improve my jquery / javascript syntax. Is this a better way of writing?
if (ok) var mymsg = '& lt; P id = "ok-box" & gt; + "You're good to go" + '& lt; / P & gt; '; } Other {var mymsg = '& lt; P id = "no-fine-box" & gt; + "Error" + '& lt; / P & gt; '; }
I was wondering if jquery / javascript had the same syntax as the following PHP syntax, it would be great:
$ mymsg = ($ Ok)? "You're good to go": "Error";
You mean like:
var mymsg = OK? '& Lt; P id = "fine-box" & gt; You're good to go & lt; / P & gt; : '& Lt; P id = "no-fine-box" & gt; Error & lt; / P & gt; ';
It does! :)
Comments
Post a Comment