Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery .text() issues
    text
    copied!<p>I'm learning HTML/CSS/JS/jQuery, and so decided to make a calculator to see if I could. I've done most of the HTML/CSS design (well, basic enough CSS for it to be usable and the HTML may be subject to change), and moved onto the Javascript. What I'm trying to do first of all is to make it so when you click on a number, it appends it to the end of the result text (unless its 0 and the result is 0). If you look at the Javascript section in the jsFiddle link I've put at the bottom of this question, you can see what I tried. I ran JSLint and got the following errors, but didn't understand them:</p> <blockquote>Error: Problem at line 4 character 9: Expected an assignment or function call and instead saw an expression. val text = $(this).text(); Problem at line 4 character 12: Missing semicolon. val text = $(this).text(); Implied global: $ 1,2,4,5,6, alert 3, val 4, text 4,5,6</blockquote> <p><a href="http://jsfiddle.net/amx3m/5/" rel="nofollow">jsFiddle link to the calculator in progress</a></p> <p>EDIT: Also, if anyone would like to suggest a difference approach to the calculator's HTML, please do so (I think the current method looks ugly).</p> <p>EDIT 2: The val instead of var <strong>has been said.</strong> After correcting my code, the result is still not appending the number clicked. <strong>This is the question now.</strong></p> <p>EDIT 3: And as I made that edit, I found an answer has been edited to correct this. <strong>THANKS FOR ANSWERING! :)</strong></p> <p>Also, <a href="http://jsfiddle.net/amx3m/11/" rel="nofollow">here's the working jsFiddle</a>.</p>
 

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