I have html output in paging section like this;
<p> <strong class="active">1</strong> <a href="http://localhost/project/report_nc/search_now/1">2</a> <a href="http://localhost/project/report_nc/search_now/2">3</a> <a href="http://localhost/project/report_nc/search_now/1">Next »</a> </p>
Now i need to add attribute “onclick” using jquery. BUt unfortunately “onclick” attribute cannot be set with jquery. At the same time i came up with an idea : taking a single anchor tag (i.e. <a href="http://localhost/project/report_nc/search_now/2"></a>) and replace it by a new anchor tag (i.e. <a href="javascript:void(0)" onclick="myFunction(2)"></a>).
How would i do it with jquery? The idea is to post the form while clicking on the paging links.
SOLVED !
Thank you all for your kind responses……I guess there was a minor mistake in my code; as i was looking through the code posted by umesh i noticed “onClick“…yes i was using “onclick” instead of “onClick“. Now it has worked in FF and hopefully it will work in IE too.
Value of the anchor can be used to pass the value to function
myFunction. If Anchor doesn’t contain any value, don’t do anything.Working Test code as below: