我正在可编辑电子邮件通知对话框中编写这个简单的 html:
<!DOCTYPE html>
<html>
<body>
<p id="demo"> </p>
<script type="text/javascript">
document.getElementById("demo").innerHTML = "this is from JS";
</script>
</body>
</html>
但是我无法在生成的电子邮件中看到字符串“this is from JS”。不确定我做错了什么?有什么指点吗?
最佳答案
你有你的JS,但你似乎从来没有调用过它。 尝试在加载或就绪函数中运行。
<script type="text/javascript">
window.onload = function() {
document.getElementById("demo").innerHTML = "this is from JS";
};
$( document ).ready(function() {
document.getElementById("demo").innerHTML = "this is from JS";
});
</script>
我认为这就是您正在尝试做的事情。
更新:
好吧,我找到了另一个适合你的功能。这是FIDDLE .
<body>
<p id="demo"></p>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("demo").innerHTML = "this is from JS";
});
</script>
</body>
关于javascript - 在 Jenkins 的可编辑电子邮件通知对话框中使用 <script> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29928449/