简体   繁体   中英

Jquery tablesorter plugin is not working

I am a newbie to MVC. Please forgive me for this newbie question. I am using JQuery table sorter plugin for sorting a html table. I am using this tablesorter plugin. But this one doesn't seem to work.

My javascript code:

    <head>
                <title>Test Header</title>
              <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.min.js"</script>
              <script src="~/Scripts/jquery-latest.js"></script>
              <script type="text/javascript" src="~/Scripts/jquery.tablesorter.js"></script> 
                <script type="text/javascript">
                    $(document).ready(function () {
                        alert("hi");
                        $("#tab").tablesorter();
                    }
            );
                </script>
            </head>

HTML Code:

<div>
    <table id="tab" class="tablesorter">
        <thead>
            <tr>
                ---Header part---
            </tr>
        </thead>
        <tbody>
            ---Body Part---
        </tbody>
    </table>
</div>

Please help me. Thanks in advance :)

您需要在tablesorter.js之前包含jquery库 ,并且仅包含tablesorter js文件之一

You don't need to include 2 tablesorter library. You need just one. You could include just the "jquery.tablesorter.min.js".

Look the difference between "file.js" and "file.min.js": What's the difference between jquery.js and jquery.min.js?

And you also need to include jquery library.

Example:

<head>
    <title>Test Header</title>
    // Here you need to include jquery library
    <script src="~/Scripts/jquery.tablesorter.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#tab").tablesorter();
        });
    </script>
</head>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM