How I use onClick in jquery?
<p>I am new in jquery and I don't know very much about it but I have been trying to generate Excel and PDF from HTML using jquery. For that I use following code :</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Assignment to generate excel&lt;/title&gt;
    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="~/Contents/jquery-1.9.1.js"&gt;&lt;/script&gt;  
    &lt;script src="~/tableExport/tableExport.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does export feature *@   --&gt;
    &lt;script src="~/tableExport/jquery.base64.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does convert the content to base64  *@ --&gt;  
    &lt;script src="~/tableExport/html2canvas.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does export to image feature *@ --&gt;  
    &lt;script src="~/tableExport/jspdf/libs/base64.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does  convert the content to base64 for pdf *@ --&gt;  
    &lt;script src="~/tableExport/jspdf/libs/sprintf.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does export feature for pdf *@ --&gt;  
    &lt;script src="~/tableExport/jspdf/jspdf.js"&gt;&lt;/script&gt; &lt;!-- @*Main file which does export feature for pdf *@ --&gt;  
&lt;/head&gt;
&lt;body&gt;
    &lt;table id="activity" border="1" width="50%" &gt;
            &lt;tr&gt;
            &lt;th&gt;Country&lt;/th&gt;
            &lt;th&gt;Population&lt;/th&gt;
            &lt;th&gt;Date&lt;/th&gt;
            &lt;th&gt;%ge&lt;/th&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
            &lt;td&gt;Chinna&lt;/td&gt;
            &lt;td&gt;1,363,480,000&lt;/td&gt;
            &lt;td&gt;March 24, 2014&lt;/td&gt;
            &lt;td&gt;19.1&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;td&gt;India&lt;/td&gt;
            &lt;td&gt;1,241,900,000&lt;/td&gt;
            &lt;td&gt;March 24, 2014&lt;/td&gt;
            &lt;td&gt;17.4&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;td&gt;United States&lt;/td&gt;
            &lt;td&gt;317,746,000&lt;/td&gt;
            &lt;td&gt;March 24, 2014&lt;/td&gt;
            &lt;td&gt;4.44&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;td&gt;Indonesia&lt;/td&gt;
            &lt;td&gt;249,866,000&lt;/td&gt;
            &lt;td&gt;July 1, 2013&lt;/td&gt;
            &lt;td&gt;3.49&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;td&gt;Brazil&lt;/td&gt;
            &lt;td&gt;201,032,714&lt;/td&gt;
            &lt;td&gt;July 1, 2013&lt;/td&gt;
            &lt;td&gt;2.81&lt;/td&gt;
            &lt;/tr&gt;

    &lt;/table&gt;  


    onClick ="$('#activity').tableExport({type:'pdf',escape:'false'});"

&lt;script&gt;  
    $(document).ready(function () {  
        $('#exportexcel').bind('click', function (e) {             
            $('#activity').tableExport({ type: 'excel', escape: 'false' });  
        });  
        $('#exportpdf').bind('click', function (e) {             
            $('#activity').tableExport({ type: 'pdf', escape: 'false' });  
        });  
        $('#exportimage').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'png', escape: 'false' });  
        });  
        $('#exportcsv').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'csv', escape: 'false' });  
        });  
        $('#exportppt').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'powerpoint', escape: 'false' });  
        });  
        $('#exportxml').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'xml', escape: 'false' });  
        });  
        $('#exportword').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'doc', escape: 'false' });  
        });  
        $('#exporttxt').bind('click', function (e) {  
            $('#activity').tableExport({ type: 'txt', escape: 'false' });  
        });  

    });  
&lt;/script&gt;  


&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>But when I run this code in browser then I get following output </p>

<p><a href="https://i.stack.imgur.com/UIjbR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UIjbR.png" alt="enter image description here"></a></p>

<p>I don't have idea how to use onClick event on this case so when I click on export excel or export PDF button I generate this files.</p>

<p>If anybody have idea about it then please help me.</p>

<p>Thanks in advance.</p>