[英]how do I create a popup that contains table and has a close button?
I am trying to create a popup when my link is clicked. 单击链接时,我试图创建一个弹出窗口。 I have been looking all over and all I could find was a html code like this
我一直在寻找,我能找到的只是一个这样的html代码
<p onClick="confirm('Correct?')" </p>
What I am trying to create is a popup that display a table with name, zip code etc 我要创建的是一个弹出窗口,显示带有名称,邮政编码等的表格
so basically instead of the popup displaying correct like the code above does?, I want it to display somethings of my own choosing. 因此,基本上,我希望它显示自己选择的内容,而不是像上面的代码那样显示正确的弹出窗口? I am looking for one that has a close button at the top it.
我正在寻找一个顶部带有关闭按钮的按钮。
Thanks everyone. 感谢大家。
So. 所以。 You'll need a javascript function named showTable() and a div having an id: popup.
您将需要一个名为showTable()的javascript函数和一个ID为:popup的div。 Change code to:
<p onClick="ShowTable(ID)" </p>
, where ID is the table's ID. 将代码更改为:
<p onClick="ShowTable(ID)" </p>
,其中ID是表的ID。 Store the table's values in a javascript array. 将表格的值存储在javascript数组中。
The ShowTable should consist of: ShowTable应该包含:
function showTable(id){document.getElementById("popup").style.display=block;
document.getElementById("popup").innerHTML=table[id];}
Also, the table[id] should conatin this too: <a href="#" onclick="closePopup();">Close popup</a>
此外,表[id]也应使用以下格式:
<a href="#" onclick="closePopup();">Close popup</a>
And add this function: 并添加此功能:
function closePopup(){
document.getElementById("popup").style.display=none;
}
To make it more designed, you could use jQuery animations. 为了使其更具设计感,您可以使用jQuery动画。
Perhaps the option that requires the least amount of work on your end would be using jQuery UI, which has a Dialog plugin. 可能需要最少工作量的选项可能是使用带有对话框插件的jQuery UI。 You would need to be somewhat familiar with jQuery, though.
不过,您需要对jQuery有所了解。 Here's the link: http://jqueryui.com/demos/dialog/
这是链接: http : //jqueryui.com/demos/dialog/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.