div clicks jquery

Evan Cutler
Evan Cutler used Ask the Experts™
on
greetings...
I have a series of divs with the same class...

<div class="divclass">some text1</div>
<div class="divclass">some text2</div>
<div class="divclass">some text3</div>
<div class="divclass">some text4</div>

if I did a $('.divclass').click(function () {
     alert ( $('.divclass').text);
})

it gives me all of the divs...how can I tweak the javascript/jquery alone to give me the text of the one div that's clicked?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
use $(this)

$('.divclass').click(function () {
     alert (    $(this).text()    );
})

Open in new window

Evan CutlerVolunteer Chief Information Officer

Author

Commented:
and that's why you are the genius.... :)

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial