I have two divs with some elements in them (images, text, etc.), and I need to know which div is holding the element that was clicked. For example:
- If I click on any element in div 1, then redirect to “pagina1.php”
- If I click on any element in div 2, then redirect to “pagina2.php”
How can I do this in jquery?
You can bind the click event to all the elements inside your divs, you can find out here how to do it http://api.jquery.com/click/, you could make something like this for each div:
And you have to do the same for div#2.
You have to notice that the selector that I made is just for the first children of the div element.
Saludos.