我正在寻找一种方法来清除Bootstrap模式中包含的HTML表单中找到的所有元素,而无需刷新页面.
目前:
用户输入数据并关闭模态.
当用户重新打开模态时,先前输入的数据仍然存在.
如何在模式对话框的关闭事件期间完全清除表单中的所有元素,以便当用户重新打开它时,它们总是获得新鲜的干净输入等?
我有以下代码,我想更新到Python 3.x所需的库将更改为http.client和json.
我似乎无法理解如何做到这一点.你能帮忙吗?
import urllib2
import json
data = {"text": "Hello world github/linguist#1 **cool**, and #1!"}
json_data = json.dumps(data)
req = urllib2.Request("https://api.github.com/markdown")
result = urllib2.urlopen(req, json_data)
print '\n'.join(result.readlines())
Run Code Online (Sandbox Code Playgroud) 我学会了如何让NGINX返回503
客户错误页面,但我无法了解如何执行以下操作:
示例配置文件:
location / {
root www;
index index.php;
try_files /503.html =503;
}
error_page 503 /503.html;
location = /503.html {
root www;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,根据上面的代码,如果503.html
在我的根目录中找到一个被调用的页面,该站点将把该页面返回给用户.
但似乎虽然上面的代码可以在有人只是访问我的网站时输入
它不会捕获如下请求:
使用我的代码,用户仍然可以看到配置文件页面或其他任何页面index.php
.
问题:
我如何陷阱请求所有页面在我的网站,并转发给503.html
时503.html
出现在我的根文件夹是什么?
有没有办法根据它的自定义属性comment_id删除DIV?
我有以下代码,但它还没有完成.
<script type="text/javascript">
$('.delete_comment').live('click', function() {
// Url we request data from
$.get( "http://www.site.com/pages/delete/user_comment.php",
// Url parameters to send
{id:$(this).attr('comment_id'),c:'yes'},
// Output data from php file generated by PHP echo.
function(data)
{
var comment_id = $(this).attr('comment_id').val();
//alert(comment_id);
if (comment_id == data) {
$(this).remove();
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我目前正在学习async await fetch
,我创建了以下示例来帮助我学习。
下面的工作示例:
url
从每个返回中提取json
img
元素img
元素附加到文档正文。请注意,promise2
故意将错误的路径设置为强制 http 状态 404。
如果这三个承诺中的任何一个发生了这个错误,我该如何处理?
// the big promise.
async function getAsyncData() {
try {
// attempt to resolve 3 individual unrelated promises...
let promise1 = await fetch('https://dummyimage.com/48x48/4caf50/ffffff.jpg&text=.jpg');
let promise2 = await fetch('https://dummyimage.com/bad/url/here/48x48/e91e63/ffffff.png&text=.png');
let promise3 = await fetch('https://dummyimage.com/48x48/00bcd4/ffffff.gif&text=.gif');
// we create an html img element and set its src attribute to the thumbnailUrl...
var img = document.createElement('img');
img.src …
Run Code Online (Sandbox Code Playgroud)我在网上找到了以下代码,并希望将其改编为我现有的代码.
这是在我找到的点击中显示/隐藏数据系列的代码:
http://jsfiddle.net/asgallant/6gz2Q/
到目前为止,这是我的改编:
function drawChart() {
var data = new google.visualization.arrayToDataTable([
['Draw', '1997', '1998'],
['1', 1236777, 1408007],
['2', 834427, 572882],
['3', 2164890, 1614181],
['4', 1893574, 3897171],
['5', 2851881, 673906],
['6', 359504, 630853]
]);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
// create columns array
var columns = [];
// display these data series by default
var defaultSeries = [1];
var series = {};
for (var i = …
Run Code Online (Sandbox Code Playgroud) 在研究动态导航标签的过程中,我决定在用户点击他们选择的标签时添加淡入效果.
当模态首次加载时,html的以下行使故障显示HOME选项卡.
<div id="home" class="tab-pane active">
Run Code Online (Sandbox Code Playgroud)
以上工作正常,但......
如果我用以下的html代码替换上面的代码...
<div id="home" class="tab-pane active fade in">
Run Code Online (Sandbox Code Playgroud)
当模态首次加载时,div home 不会淡入.它仅在用户单击其他选项卡然后返回HOME选项卡时才起作用.
我的问题是,这种行为是否正常?
<!-- 1. BOOTSTRAP v4.0.0 CSS !-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- 2. GOOGLE JQUERY JS v3.2.1 JS !-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- 3. BOOTSTRAP v4.0.0 JS !-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- Toggleable / Dynamic Tabs -->
<nav class="nav nav-tabs nav-justified">
<a class="nav-item nav-link active" data-toggle="tab" href="#home">Home</a>
<a class="nav-item nav-link" data-toggle="tab" href="#menu1">Menu 1</a>
<a …
Run Code Online (Sandbox Code Playgroud)我在网上发现了这个非常酷的示例,介绍了如何使用WebView
Deno 运行。
是否可以从放置在 html 模板内的 HTML 按钮元素调用 Deno 应用程序内的函数?
看一看:
// Importing the webview library
import { WebView } from "https://deno.land/x/webview/mod.ts";
// Creating an HTML page
let html = `
<html>
<body>
<h1>Hello from deno v${Deno.version.deno}</h1>
<button type="button" onclick="test()">RUN TEST FUNCTION</button>
</body>
</html>
`;
function test() {
console.log('You really can do that!');
}
// Creating and configuring the webview
const webview = new WebView({
title: "Deno Webview Example",
url: "data:text/html," + html,
// url: 'https://www.google.com',
width: 768,
height: …
Run Code Online (Sandbox Code Playgroud) 为了便于可视化,下面是记录查找表。
我似乎在网上找不到任何地方可以告诉您其中哪些应该还包含charset=utf-8
.
我应该假设它与文本类似吗?
看一看:
const MEDIA_TYPES: Record<string, string> = {
".md": "text/markdown",
".html": "text/html",
".htm": "text/html",
".json": "application/json",
".map": "application/json",
".txt": "text/plain",
".ts": "text/typescript",
".tsx": "text/tsx",
".js": "application/javascript",
".jsx": "text/jsx",
".gz": "application/gzip",
".css": "text/css",
".wasm": "application/wasm",
".mjs": "application/javascript",
".otf": "font/otf",
".ttf": "font/ttf",
".woff": "font/woff",
".woff2": "font/woff2",
".conf": "text/plain",
".list": "text/plain",
".log": "text/plain",
".ini": "text/plain",
".vtt": "text/vtt",
".yaml": "text/yaml",
".yml": "text/yaml",
".mid": "audio/midi",
".midi": "audio/midi",
".mp3": "audio/mp3",
".mp4a": "audio/mp4",
".m4a": "audio/mp4",
".ogg": "audio/ogg",
".spx": "audio/ogg",
".opus": "audio/ogg",
".wav": "audio/wav", …
Run Code Online (Sandbox Code Playgroud) 使用以下URL示例,我如何从中获取用户名?
http://www.mysite.com/username_here801
正则表达式解决方案很酷.
以下示例仅获取域名:
var url = $(location).attr('href');
alert(get_domain(url));
function get_domain(url) {
return url.match(/http:\/\/.*?\//);
}
Run Code Online (Sandbox Code Playgroud)
jQuery解决方案也是可以接受的.
javascript ×6
jquery ×4
deno ×2
async-await ×1
charts ×1
css ×1
forms ×1
html ×1
mime-types ×1
nginx ×1
promise ×1
python ×1
python-3.x ×1
refresh ×1
regex ×1
typescript ×1
webview ×1