亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

<script> 在燒瓶 html 頁面中的位置

<script> 在燒瓶 html 頁面中的位置

郎朗坤 2022-06-16 15:33:38
我希望使用此代碼(從此處)淡出我的 Flash 消息:<script type="text/javascript">setTimeout(function() {$('#stepMessage').fadeOut('slow');}, 3000); </script>我的完整腳本如下所示:解決方案:在 base.html 中:{% 擴展 'bootstrap/base.html' %}{% block scripts %}<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> <-- included JQuery{% raw %}<script type="text/javascript">window.setTimeout(function() {$('#stepMessage').fadeOut('slow');}, 3000); </script> <-- added function{% endraw %}{% endblock %}{% extends "base.html" %}{% import 'bootstrap/wtf.html' as wtf %}在 index.html 中,我現在可以使用之前定義的函數:{% block content %}    <div class="container">     .     .     .    </div>    {% with messages = get_flashed_messages(with_categories=true) %}    {% if messages %}        {% for message in messages %}            {% set lvl = "alert-danger" if message[1]["result"] == False else "alert-info" %}        <div id="stepMessage" class="alert {{ lvl }}" role="alert">{{  message[1]["content"] }}</div>        {% endfor %}    {% endif %}    {% endwith %}    {% block app_content %}    {% endblock %}{% endblock %}感謝@Rishi Dev 的幫助
查看完整描述

1 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

您需要包含 JQuery。將此標簽粘貼到模板中的腳本標簽之前

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>


查看完整回答
反對 回復 2022-06-16
  • 1 回答
  • 0 關注
  • 122 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號