Dementic Dementic - 1 year ago 79
jQuery Question

applying the same .click event to two diffrent divs

i have two diffrent divs (code was simplified, this is not the actual code.)

<div id="test"></div>
<div id="funt"></div>

what i want is, to attach the same click event to
something like:

$('#test').click(function() {
$('#funt).click(function() {

function DoWork(){

but isnt there a way to define multiple div's the same click event ?

lets say ( yes, i know this does not work!!! )


Answer Source


$("#test, #funt").click(DoWork);

See Multiple Selector.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download