<head> <script type="text/javascript"> var t=""; var s=false; function change(){ var ti=""; var div=document.getElementById("test"); var c=0; if(parseInt(div.style.height)<=0){ t=true; }else if(parseInt(div.style.height)>=20){ t=false; s=true; } if(t){ c=1; }else{ c=-1; } div.style.height=parseInt(div.style.height)+c+"px"; ti=window.setTimeout(change,100); if(s&&t){ s=false; window.clearTimeout(ti); } } </script> </head><body> <div id="test" style="position:absolute;left:0px;height:0px;width:1000px;top:0px;overflow:hidden" align="center">error</div> <input type="button" onClick="change()" value="change"> </body> 这样试试
ajax和jquery结合着一起使用的吧...
你的这个方法基本是可行的,你的代码一上来也是显示的。我想要一上来隐藏的 已经改好了。但是我想要重复利用。也就是要把提示的内容进行修改。想用传参的方法。 var t = ""; var s = false; function change(neirong) { var ti = ""; var div = document.getElementById("test"); div.style.display="block"; div.innerHTML=neirong; var c = 0; if (parseInt(div.style.height) <= 0) { t = true; } else if (parseInt(div.style.height) >= 20) { t = false; s = true; } if (t) { c = 1; } else { c = -1; } div.style.height = parseInt(div.style.height) + c + "px"; ti = window.setTimeout(change, 100); if (s && t) { s = false; window.clearTimeout(ti); } }<div id="test" style="position:absolute;left:0px;height:0px;width:1000px;top:0px;overflow:hidden;display:none;" align="center"></div> <input type="button" onClick="change('xxxx')" value="change">为什么我这个xxxx没有传过去求解。。是我把原来的东西往光了? - -
function floatDoLogin() {
var sUsername = $.trim($('#floatLoginName').val());
var sPwd = $('#floatLoginPwd').val(); if(sUsername == '') {
floatLoginTishi('请输入用户名');
return false;
}else if(sPwd == ''){
floatLoginTishi('请输入密码');
return false;
}else {
$.getJSON(
__GLOBAL_VARS.SYS_PATH_WEB + '/?_c=account&_a=doLogin&callback=?',
{
loginusername: sUsername,
password: sPwd,
remember: '1',
handler:'jsonHandler'
},
function(json){
if(json.code < 0 ) {
floatLoginTishi(json.data);
}else {
floatLoginTishi('登录成功');
window.location.reload();
}
}
);
}
}
<script type="text/javascript">
var t="";
var s=false;
function change(){
var ti="";
var div=document.getElementById("test");
var c=0;
if(parseInt(div.style.height)<=0){
t=true;
}else if(parseInt(div.style.height)>=20){
t=false;
s=true;
}
if(t){
c=1;
}else{
c=-1;
}
div.style.height=parseInt(div.style.height)+c+"px";
ti=window.setTimeout(change,100);
if(s&&t){
s=false;
window.clearTimeout(ti);
}
}
</script>
</head><body>
<div id="test" style="position:absolute;left:0px;height:0px;width:1000px;top:0px;overflow:hidden" align="center">error</div>
<input type="button" onClick="change()" value="change">
</body>
这样试试
你的这个方法基本是可行的,你的代码一上来也是显示的。我想要一上来隐藏的 已经改好了。但是我想要重复利用。也就是要把提示的内容进行修改。想用传参的方法。 var t = "";
var s = false;
function change(neirong) {
var ti = "";
var div = document.getElementById("test");
div.style.display="block";
div.innerHTML=neirong;
var c = 0;
if (parseInt(div.style.height) <= 0) {
t = true;
} else if (parseInt(div.style.height) >= 20) {
t = false;
s = true;
}
if (t) {
c = 1;
} else {
c = -1;
}
div.style.height = parseInt(div.style.height) + c + "px";
ti = window.setTimeout(change, 100);
if (s && t) {
s = false;
window.clearTimeout(ti);
}
}<div id="test"
style="position:absolute;left:0px;height:0px;width:1000px;top:0px;overflow:hidden;display:none;"
align="center"></div>
<input type="button" onClick="change('xxxx')" value="change">为什么我这个xxxx没有传过去求解。。是我把原来的东西往光了? - -