I am getting unexpected results with jQuery trying to set the \"click\" method of a div. Please see this jsfiddle. Be sure to open the console window. Click the word a few times
You should bind the click
event outside the toggleDiv
function. The current code will register new click
event handler every time the elements in $('#test')
is clicked, with exponential growth (since all previous click
handler will generate a new click
handler, so the number of handlers will double with every click).