Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Guys somebody can explain me what this code does in a calculator?

JavaScript
$('#buttons div').click(function()
   {
       clicked = $(this).text();
       buttonPressed();
   })
Posted

JavaScript
$('#buttons div')

This means a div control of ID 'buttons'

Based on full code, it does: on click of div named 'buttons', clicked will be assigned text of that div and buttonPressed method will be called.
 
Share this answer
 
Comments
prashant patil 4987 11-Jan-13 1:38am    
nICE sandeep. My +5. :)
First of all, this is a very ineffective method of learning. There is no sense in trying to understand anything written by who-knows-who for who-knows-what purpose. If you read article on technology and tried to write code by yourself, understanding each letter you write, it would make sense.

So, you want to know what does this code mean? Without any context? The answer is simple: this is gibberish. Please see:
http://en.wikipedia.org/wiki/Gibberish[^].

In principle, I could imagine that this code fragment might have some sense in some context, where buttonPressed and clicked are defined (if clicked is introduced locally, it would never be used, but if it is defined outside, this is just a very bad coding style), but… I just don't even want to thing about it. Why wasting time on something which is just a result of wrong approach?

It looks like this fragment tries to use jQuery library. What to learn it? — do it:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^],
http://docs.jquery.com/How_jQuery_Works[^].

Good luck,
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900