haitruonginfotech haitruonginfotech - 3 months ago 10
Javascript Question

How to get link URL from JavaScript?

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>
.

Py. Py.
Answer

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