在Facebook中,当您松开互联网连接时,您会看到一条消息"没有互联网连接.请重试?" 并且您从在线更改为离线.我希望在我的网站上.我怎样才能做到这一点?
我希望使用JavaScript每5秒执行一次php程序.我怎样才能做到这一点?
我试过用:
<script type="text/javascript">
setInterval(
function (){
$.load('update.php');
},
5000
);
</script>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我想使用复选框显示和隐藏表格.该表出现并消失,没有任何问题.但是没有检查复选框.我有Jquery v1.8.2.我有以下代码:
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$('#checkbox').toggle(function() {
document.getElementById('table').style.display = "inline";
}, function() {
document.getElementById('table').style.display = "none";
});
</script>
</head>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="checkbox" id="checkbox">
<br />
<table id="table" style="display: none;">
<tr>
<td>
<input type="file" name="file">
<input type="submit" name="upload" value="upload">
</td>
</tr>
</table>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8"/>
<script type = "text/javascript" src = "js/jquery.js" ></script>
</head>
<body>
<div id = 'div'>
<div id = "1">
</div>
<div id = "2">
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的JavaScript代码是:
$(document).ready(function(){
var lastcommentq = document.getElementById('div').lastChild.id;
alert(lastcommentq);
});
Run Code Online (Sandbox Code Playgroud)
它应警告div的lastchild的id,id为'div',即'2',但我收到警告为"undefined".我不知道我做错了什么.请帮我.
除了垂直对齐,还有其他选择吗?
为了使用垂直对齐,我必须将显示设置为表格单元。当我将显示设置为table-cell时,我设置的div高度不起作用。我在该div上将溢出Y设置为自动。我想做的是从div的底部对齐div内的内容...我无法做到这一点。还有其他选择吗?
这就是我现在所拥有的:
#container{
height:375px;
border:1px solid #000;
position:relative;
overflow-y:auto;
display:table-cell;
vertical-align:bottom;
}
#container > div{
margin:0;
margin-bottom:5px;
width:660px;
position:relative;
}
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
<?php
$i=5;
while($i > 0){
echo '
<table width="500px" border="1">
<tr>
<td>
<button id="button">Show comments</button>
</td>
</tr>
<tr>
<td id="comments" style="display:none;height:300px;width:100%;"></td>
</tr>
</table>
<script type="text/javascript">
$("#button").toggle(
function (){
$("#button").text("Hide Comments");
document.getElementById("comments").style.display="inline";
},function (){
$("#button").text("Show Comments");
document.getElementById("comments").style.display="none";
}
);
</script>
<script type="text/javascript" src="jquery.js"></script>
';
$i--;
}
?>
Run Code Online (Sandbox Code Playgroud)
单击"显示注释"按钮时,应显示注释框.它适用于第一个.但它对其他人不起作用.出了什么问题?