jquery - How to add onClick event to an a tag with class -


here's have on page

<a class="download-link" href="http://www.test.com/pages-">pages 1</a> 

below result want achieve jquery.

<a class="download-link" href="http://www.test.com/pages-1.asp" onclick="_sz.push(['event', 'pdf', 'download', ('report') ])">pages 1</a> 

jquery

<script type="text/javascript">/ $('.download-link').each(function(){     this.href += '-1.asp';     this.attr('onclick', '_sz.push(['event', 'pdf', 'download-request', ('report') ])'); }) </script> 

try one.

$('.download-link').bind('click', function (event) {     _sz.push(['event', 'pdf', 'download', ('report')]) }); 

i hope. helps you.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -