Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在Popover中使用显示、隐藏和切换_Jquery_Html - Fatal编程技术网

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>