On Fri, Apr 10, 2009 at 5:46 PM, thought <thou...@orcon.net.nz> wrote:

>
> Given this code:
>
> <DIV id="div_one"></DIV>
> <DIV id="div_two"></DIV>
> <DIV id="div_three"></DIV>
> <DIV id="div_four"></DIV>
>
> Lets say that the user is invited to click one one of these divs.
>
> How do I get the id of the div that was clicked ?
>

<script type="text/javascript">
     $(document).ready(function() {
          $("div[id^='div_']").click(function() {  // when a div whose ID
attribute starts with "div_" is clicked...
               alert($(this).attr('id'));
          });
     });
</script>

-- 
I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to