How to detect a certain HREF for every hyperlink

Go To StackoverFlow.com

1

             $(document).ready(function(){
                $(".item_delete").easyconfirm({locale: {
                        title: 'Select Yes or No', 
                        text: 'Do you really want to delete this product?',
                        button: ['No','Yes']
                }});
                $(".item_delete").click(function(){
                    $(location).attr('href',$(this).attr("href"));
                });
            });

The above code is my code that I want to run but, it's not working for MULTIPLE links, maybe because the code can't figure out which HREF to choose.

            <a href="<?php echo "index.php?module=account&del_product=".$row['product_code']; ?>" class="item_delete ui-icon ui-icon-trash"></a>

If the links has a multiple href's like below, how the jquery detects the specific link that I clicked?

             <a href="index.php?module=account&del_product=1"></a>
             <a href="index.php?module=account&del_product=2"></a>
             <a href="index.php?module=account&del_product=3"></a>
             <a href="index.php?module=account&del_product=4"></a>
             <a href="index.php?module=account&del_product=5"></a>
             <a href="index.php?module=account&del_product=6"></a>

I appreciate for your cooperation...

By the way, Im using this "Easy Confirm Dialog" plugin for jQuery - http://projectshadowlight.org/jquery-easy-confirm-dialog/

2012-04-05 02:23
by daison12006013


3

Using $(this), you can get the href of the currently clicked hyperlink

    $("a.item_delete").on("click", function(){
        console.log($(this).attr("href"));
    });
2012-04-05 02:28
by DG3
thanks sir for your answer ^_ - daison12006013 2012-04-05 02:32
glad to help. if my answer helped you, feel free to accept it as answer : - DG3 2012-04-05 02:35
yah, my bad that I only limit the anchor for item_delet - daison12006013 2012-04-05 02:41
you need to update $("a.item_delete" - DG3 2012-04-05 03:03
@DG3 Do not be sad if he did not accept the answer. I have voted up yours - OammieR 2012-04-05 03:31
Ads