Javascript Jquery单击按钮打开弹出窗口进行引导
当我点击下面的按钮Javascript Jquery单击按钮打开弹出窗口进行引导,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,当我点击下面的按钮 <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> Launch demo modal </button> 启动演示模式 我打开下面的弹出窗口(模式) &时代; 情态标题 ... 接近 保存更改 我参考下面的例子 我的问题: 如何使用javascript/jquery在单击按钮时打开#myModal
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
启动演示模式
我打开下面的弹出窗口(模式)
&时代;
情态标题
...
接近
保存更改
我参考下面的例子
我的问题:
如何使用javascript/jquery在单击按钮时打开#myModal
任何帮助都将不胜感激
谢谢。答案在您提供的示例链接上: i、 e
使用一行JavaScript调用id为myModal的模态:
$('#myModal').modal('show');
给一个ID来唯一标识按钮,比如说
myBtn
// when DOM is ready
$(document).ready(function () {
// Attach Button click event listener
$("#myBtn").click(function(){
// show Modal
$('#myModal').modal('show');
});
});
下面提到的链接用示例给出了清晰的解释 来自同一链接的代码
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#dialog").dialog({
modal: true,
autoOpen: false,
title: "jQuery Dialog",
width: 300,
height: 150
});
$("#btnShow").click(function () {
$('#dialog').dialog('open');
});
});
</script>
<input type="button" id="btnShow" value="Show Popup" />
<div id="dialog" style="display: none" align = "center">
This is a jQuery Dialog.
</div>
$(函数(){
$(“#对话框”)。对话框({
莫代尔:是的,
自动打开:错误,
标题:“jQuery对话框”,
宽度:300,
身高:150
});
$(“#btnShow”)。单击(函数(){
$('dialog')。dialog('open');
});
});
这是一个jQuery对话框。
我想再问一个问题。我在莫代尔。我想在js代码函数myModal()中设置值{$('#myModal').modal('show');var s=document.getElementsByName(“xx”);s.value=“adsadasdas”;};但它不起作用为什么?getElementsByName检索数组-您必须使用如下索引访问elment-var s=document.getElementsByName(“xx”)[0];如果你有skype,请给我加上“sonersevinc92”我总是在StatkCverloff.com上问问题谢谢
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#dialog").dialog({
modal: true,
autoOpen: false,
title: "jQuery Dialog",
width: 300,
height: 150
});
$("#btnShow").click(function () {
$('#dialog').dialog('open');
});
});
</script>
<input type="button" id="btnShow" value="Show Popup" />
<div id="dialog" style="display: none" align = "center">
This is a jQuery Dialog.
</div>