【发布时间】:2021-10-31 18:50:40
【问题描述】:
我已经对此进行了几个小时的试验,但我仍然感到困惑。
我试图在单击链接([a] 标记)时打开一个 JQuery UI 对话框(模式),从链接的 href 获取对话框窗口的内容。
到目前为止,我(从各个地方收集到)testb.html 是一个简单的 html 片段:
<div><p>Some text</p><p>more text</p</div>
这个想法是,当点击锚(链接)时,testb.html 的内容会出现在对话框中。
为什么这不起作用???
David(70 岁的阿尔茨海默病前程序员,几乎没有 HTML 经验)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery test</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script>
$("a.modal").click(function(e) {
e.preventDefault();
$(".container").load(this.href).dialog("open");
});
</script>
</head>
<body>
<div class="container"></div>
<p><a href="testb.html" class="modal">Click!</a></p>
</body>
</html>
【问题讨论】:
标签: javascript html jquery dialog anchor