首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Javascript表排序插件不起作用

Javascript表排序插件不起作用
EN

Stack Overflow用户
提问于 2018-08-08 01:03:04
回答 2查看 31关注 0票数 1

我试图在我的代码中包含tablesorter插件,但它不起作用。我已经添加了jquery库和tablesorter文件,但它没有做任何事情。下面是我的代码:

添加的脚本:

代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="{% static 'MIDIPIRCUSSION_APP/jquery.tablesorter.js' %}"></script>

HTML代码:

代码语言:javascript
复制
    <div class="jumbotron2">
            <div class="container">
            <br>
        <center>
        <table id="myTable" class="table table-dark"  style="text-align: center">
            <thead>
                <tr>
                    <th>Fecha de Creación</th>
                    <th>Título</th>
                    <th>Duracion</th>
                    <th>Dificultad</th>

                    {% if not user.is_staff %}

                        <th>Jugar</th>

                    {% endif %}

                    <th>Configurar Bateria</th>


                    {% if user.is_staff %}
                        <th>Modificar</th>
                        <th>Eliminar</th>
                    {% endif %}

            </thead>

            {% for cancion in object_list %}
            <tbody>
                <tr>
                    <td>{{cancion.creacion}}</td>
                    <td>{{cancion.titulo}}</td>
                    <td>{{cancion.duracion}}</td>
                    <td>{{cancion.dificultad}}</td>
</tbody>
</table>

javascript代码:

代码语言:javascript
复制
<script>
$(document).ready(function() { 
  $("myTable").tablesorter(); 
    });
</script>
EN

回答 2

Stack Overflow用户

发布于 2018-08-08 01:14:51

选择器无效...应该是$("#myTable")

$("myTable")正在查找不存在的标记<myTable></myTable>

票数 1
EN

Stack Overflow用户

发布于 2018-08-08 03:32:56

我发现了错误。我使用两种不同的方法加载jquery,版本不同,所以我没有使用正确的方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51731996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档