【发布时间】:2019-05-22 20:09:57
【问题描述】:
我正在尝试在引导弹出框内使用表单。一些基本的 html 工作(文本样式、按钮),但表单没有。 (onclick() javascript 操作也不做)
我尝试了几个选项,但在网上找不到任何解决方案。
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" data-html='true' data-content="
<h3>This works</h3>
<form>
This does not:<br>
<input type='text' name='firstname'><br>
Last name:<br>
<input type='text' name='lastname'>
</form>
">popover with html form</button>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script>
$(function () {
$('[data-toggle="popover"]').popover({
html: true
})
})
</script>
</body>
</html>
【问题讨论】:
-
您的 HTML 有问题。检查按钮标签的行,它没有关闭。以 data-content=" 结尾 它应该以 data-content="">Submit 之类的结尾
-
@Hema_Elmasry 结束标记向下 8 行,中间的 html 显示在弹出窗口中
标签: jquery html twitter-bootstrap