How to call a JavaScript Function from href tag in html? I have created few tabs . I want when user clicks on any tab the href along with JavaScript function should get called. How can I do it?
<?php if($order == 1){ ?>
<li class="cat-one"><a href= "javascript:loadProducts($categoryId)" > <?php echo $categoryName ?> </a></li>
<?php } ?>
This is my Javascript
<script type="javascript" >
function loadProducts($categoryId)
{
alert("Hello World!");
return false;
}
</script>
In the href tag, without specifying a link, specify your javascript function name.
For example
<a href='javascript:myFunction()'> Click Me! <a/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With