I am using JavaScript for the first time.
Please give me detailed explanation and test code.
I would like to extract 'javascript: pdfdownload' next to 'onclick' in 'href = # function' under code.
<li><a href="#" onclick="javascript:pdfDownload('NAME.pdf'); return false;"><span class="on-clickboard">
<img src="IMG1.png" alt=""></span>NAME
<span class="icon-right"><img src="IMG.JPG" alt=""></span>
</a></li>
so i use under code that if i catch button_action then give a True to 'value' variale.
var button_action = "pdfDonwload"
if(window.loaction.href.indexOf(button_action) != -1){value = 'True'}
i don't know thos try is right, and Furthermore, it may be a completely wrong-directional coding.
please help me.
you first must select tag:
var els = document.getElementsByTagName("a"); // better is use getElementById()
then get getAttribute
var value = els[0].getAttribute('onclick');
now you can set it anywhere.
i suggest you read more...!