陶氏到我在弹出框中显示DIV的内容。 [英] Dow to I display contents of a DIV in a pop up box.
本文介绍了陶氏到我在弹出框中显示DIV的内容。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在我的项目中使用这个javscript库来弹出消息
http://fabien-d.github.io/alertify.js/ [ ^ ]
我遇到的问题是我无法在警告弹出框中显示div中包含的消息。
Hello ALL,
I am using this javscript library for pop up messages in my project
http://fabien-d.github.io/alertify.js/[^]
The issue i am having is that i am unable to display a message contained in a div in an alert pop up box.
<div id ="mydiv"> Display this message in an alert box</div>
<button > show message </button>
<script type="text/javascript">
function message() {
alertify.alert(document.getElementById("mydiv").innerHTML);
}
</script>
当页面加载时...消息显示在页面上而不是在弹出框中,当我点击显示警告弹出时,它没有任何内容。
我能做错什么?
When the page loads .. the message is displayed on the page instead of in a pop up box and when i click to display the alert pop up , there is nothing in it.
What could i be doing wrong??
推荐答案
给< div>和id。
通过以下方式获取< div>
的内容:
var divText = document .GetElementById('theID')。innerHTML;
然后把它放在你的警报中:
(这是你出错的地方:) br $>
window.alert(divText);
not alertify.alert(divText);
此外,请访问W3Schools并查看他们的javaScript教程。
Give the <div> and id.
Get the contents of the <div>
via:
var divText = document.GetElementById('theID').innerHTML;
Then put that in your alert:
(Here's where you went wrong: )
window.alert(divText);
not alertify.alert(divText);
Also, go to W3Schools and check out their javaScript tutorial.
这篇关于陶氏到我在弹出框中显示DIV的内容。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文