V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
axdz
V2EX  ›  问与答

select2 与<!DOCTYPE html>不兼容?

  •  
  •   axdz · Feb 3, 2018 · 2169 views
    This topic created in 3011 days ago, the information mentioned may be changed or developed.
    在 django 的环境下,使用 select2,页面中带有<!DOCTYPE html>的情况下,select2 不能正常显示


    把<!DOCTYPE html>删除之后,显示就正常了



    代码:

    <html>
    <head>

    {% load staticfiles %}
    <script src="{% static "js/jquery-3.1.1.js" %}" type="text/javascript" charset="utf-8"></script>
    <link href="../static/css/select2.css" rel="stylesheet"/>
    <script src="../static/js/select2.js"></script>
    <script>
    $(document).ready(function() {
    $("#e1").select2({
    placeholder: "Select a State",
    allowClear: true
    });
    });
    </script>
    </head>
    <body>
    <select id="e1" style="width: 350px">
    <option value="AL">Alabama</option>
    <option value="WY">Wyoming</option>
    </select>
    </body>

    </html>

    应该怎么改?
    1 replies    2018-02-04 00:58:09 +08:00
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2161 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 00:35 · PVG 08:35 · LAX 17:35 · JFK 20:35
    ♥ Do have faith in what you're doing.