1

I have the following code :

<?php
$i = 0;
foreach($this->list as $l) { 
$link = JRoute::_("index.php?option=com_ecommerce&view=detail&id=$l->id");
<div class="quickview" id="quickview_<?php echo $i;?>">
<a href='<?php echo $link ?>' class='basic'>Quick view</a>
</div>
i++;
}
?>
<script>
jQuery(function ($){
    var link = $('.quickview .basic').val();
    $('.quickview .basic').click(function (e) {
    alert(link);
        return false;
    });
});
</script>

I can't get link from tag <a>.

2 Answers 2

1

var link =$('.quickview .basic').attr("href"); should do the trick.

Sign up to request clarification or add additional context in comments.

2 Comments

I think prop() should be used in this case
I think both are valid no? IMHO, in this case "href" is both an attr (of the html tag) and a prop (of the DOM object)
0

If you refer

I can't get link from tag <a>, please help me!

to the link you're clicking, this would work:

$(".quickview").find(".basic").click(function(e) {

     e.preventDefault();
     var url = $(this).attr("href");
     alert(url);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.