pgill pgill - 4 months ago 20
Javascript Question

How to implement same set of JavaScript/jQuery functions on multiple elements

I want to run same method for multiple div elements. the code is give here:

<div class="pages" id="oddPage">
<div class="pages" id="evenPage">

and JS code is:

function flip() {
//Something on odd page;
//Something on even page;
function flop() {
//Something on odd page;
// Something on even page;

My requirement is is I click on odd page flip() is called and if I click on even page odd function is called.

I do not know how to do it.


if there are multiple elements with this id, change it to a class because ids are unique and reference it with a .