tri*_*t77 3 javascript css jquery onclick fade
我有一个相当简单的问题。我有删除按钮,打开模态弹出窗口以确认或拒绝删除。我希望这些模态弹出窗口在单击时淡入并在取消时淡出。我已经尝试了一些不同的东西,到目前为止还没有运气。我只需要一个简单的解决方案。提前致谢。这是我的代码
<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>
Run Code Online (Sandbox Code Playgroud)
在您的参数 ( ) 上使用.fadeIn()and 而不是 on 。.fadeOut()id"delAll1"this
function showModal(id) {
$("#" + id).fadeIn('slow');
}
function hideModal(id) {
$("#" + id).fadeOut('slow');
}
Run Code Online (Sandbox Code Playgroud)
通过使用,$("#" + id)您可以通过它的 选择一个元素id,即"#" + id。
注意:从左侧边栏上的框架更改onLoad为no wrap (head)下框架以修复范围问题。