JavaScript或者Jqurey把控件id作为參数来调用
1.JavaScript把控件id作为參数调用
<script type="text/javascript">
function xx(pmba)
{
document.getElementById(pmba).style.display = "block";
}
</script>
<div id="overlay">
<input type="button" value="弹出A" onclick="xx('xa')" /><input type="button" value="弹出B" onclick="xx('xb')" />
</div>
<div class="win" id="xa">
网页a</div>
<div class="win" id="xb">窗体b</div>
2.这个弄了好一会儿,仅仅写一个Jqurey函数,通过调用不同的控件id作为參数就好了,開始不会啊。老出错
<script type="text/javascript" src="jQuery 2.0.3.js"></script>
<script type="text/javascript">
function ShowMsg(xdiv)//调用函数时,传入控件id
{
var box = 300;
var th = $(window).scrollTop() + $(window).height() / 1.6 - box;
var h = document.body.clientHeight;
var rw = $(window).width() / 2 - box;
$('#'+ xdiv).animate({ top: th, opacity: 'show', width: 600, height: 340, right: rw }, 500);//最主要就是这个<span style="color:#FF0000;">$('#'+ xdiv)</span>
return false;
}
function CloseMsg(ydiv)
{
$("#"+ydiv).animate({ top: 0, opacity: 'hide', width: 0, height: 0, right: 0 }, 500);
}
</script>
posted on 2019-05-03 18:18 xfgnongmin 阅读(130) 评论(0) 编辑 收藏 举报