Trying to use one click function for all of my div boxes. Did some research but still not able to get it working correctly. I'm new to programming so I might be going about this the wrong way, here is an example of what I'm trying to do:\[code\]<div id="test_1"> <p class="example">display this text 1</p></div><div id="test_2"> <p class="example">display this text 2</p></div><div id="test_3"> <p class="example">display this text 3</p></div>\[/code\]\[code\]$('div[id^="test"]').each(function(){ $(this).click(function(){ test = $(this).parent().find('.example').attr("p") alert(test) })})\[/code\]I thought this would work but if I click on \[code\]div\[/code\] test \[code\]2\[/code\] or \[code\]3\[/code\] the \[code\]alert\[/code\] shows \[code\]"display this text 1"\[/code\] instead of \[code\]"display this text 2"\[/code\] or \[code\]"...3"\[/code\]. Any idea what I'm doing wrong?