Jquery 如何在Popover中使用显示、隐藏和切换
我已经可以隐藏/显示或切换像这样的元素Jquery 如何在Popover中使用显示、隐藏和切换,jquery,html,Jquery,Html,我已经可以隐藏/显示或切换像这样的元素 <h4 id="h4">Hide this when needed</h4> <button id="showInput" >Show Input</button> <button id="hideTheH4">Hide Text</button> <div id="input" style="display:none;"> <input type="text" p
<h4 id="h4">Hide this when needed</h4>
<button id="showInput" >Show Input</button>
<button id="hideTheH4">Hide Text</button>
<div id="input" style="display:none;">
<input type="text" placeholder="Enter Name">
</div>
我看到了这一个,我尝试创建一个带有popover的按钮和可以使用脚本的按钮这是密码
HTML 但当我点击Popover的内容时,它不会切换H4和输入
它们有不同的吗?因为我不知道哪里出了问题,或者出了什么问题你的代码没有问题。唯一的问题是,您必须像这样将
popover.js
库文件包含到脚本中
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
下面是一个包含给定代码的示例。我刚刚包括了
popover.js
库您的代码没有问题。唯一的问题是,您必须像这样将popover.js
库文件包含到脚本中
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
下面是一个包含给定代码的示例。我刚刚加入了
popover.js
library那么你的问题是什么?当我单击popover的内容时,它不会切换id=h4和id=input的div。那么你的问题是什么?当我单击popover的内容时,它不会切换id=h4和id=input的div。顺便说一句,我使用了这个代码函数toggle_visibility(id){var e=document.getElementById(id);if(e.style.display='block')e.style.display='none';else e.style.display='block';}不起作用。顺便说一句,我使用了这个代码函数来切换可见性(id){var e=document.getElementById(id);if(e.style.display='block')e.style.display='none';else e.style.display='block';}`
$(document).ready(function(){
$('#option').popover({title: "Select", content: $("#popOptions").html(), html: true, placement: "right"}).click(function(){
$(this).popover('show');
});
});
$(document).ready(function(){
$('#showInput').click(function(){
$('#input').toggle();
})
});
$(document).ready(function(){
$('#hideH4').click(function(){
$('#h4').toggle();
})
});
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>