我有一个相当简单的问题。我有删除按钮,可以打开模式弹出窗口以确认或拒绝删除。我希望这些模式弹出窗口在单击时淡入,在取消时淡出。我已经尝试了几种不同的方法,到目前为止还没有运气。我只需要一个简单的解决方案。提前致谢。这是我的代码
<style>
div.delModal
{
position:absolute;
border:solid 1px black;
padding:8px;
background-color:white;
width:160px;
text-align:right
}
</style>
<script>
function showModal(id) {
document.getElementById(id).style.display = 'block';
//$(this).fadeIn('slow');
}
function hideModal(id) {
document.getElementById(id).style.display = 'none';
}
</script>
</head>
<body>
<input type ="button" value="delete" onclick="showModal('delAll1')">
<div class="delModal" style="display:none" id="delAll1">
<img src="images/warning.png" /> Are you sure you want to delete vessel and the corresponding tanks?<br />
<input type="button" value="Cancel" class="hide" onclick="hideModal('delAll1')"/>
<input type="button" value="Delete" onclick="delVesselAll(1)" id="delete"/>
</div>
</body>
Use .fadeIn()
and .fadeOut()
在你的id
范围 ("delAll1"
) 不开this
.
function showModal(id) {
$("#" + id).fadeIn('slow');
}
function hideModal(id) {
$("#" + id).fadeOut('slow');
}
通过使用,$("#" + id)
你可以通过它来选择一个元素id
, 那是"#" + id
.
在这里查看。
Note:更改自onLoad
to no wrap (head)
在左侧栏的框架下解决范围问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)