level 2
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.disnone{
display:none;
}
</style>
</head>
<body id="11">
1<br>2<br>3<br>4<br><hr>5<br>6<br>7<br>8<br><br><br>9<br><br><hr><br><br><br>10<br><br><br>11<br><br><br><br><hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div id="lp" style="width:500px;height: 300px;background-color: red">这是一个div</div>
<a style="text-decoration:none;" href="?pinglun=1&&page=1">评论</a>
<?php
if (isset($_GET['pinglun']) && ($_GET['pinglun'] == 1)) {
?>
<form method="post" action="huifu.php">
<table>
<tr class="tex" id="tex">
<td id="hu">
<input id="hui" type="text"name="content"style="width:700px;height:25px;" placeholder="请输入您的评论">
<button type="submit" id="ti" style="height: 25px;">发表</button>
</td>
</tr>
<table>
</form>
<?php
}
?>
<script src="jquery-3.4.1.min.js"></script>
<script>
var s;
window.onclick = function () {
s = $(document.activeElement).attr("id");
if (s != 'hui' && s != 'ti' && s != 'hu') {
$('.tex').addClass('disnone')
}
}
</script>
</body>
</html>
2020年03月16日 10点03分
4
level 2
目前的效果是,点击评论,弹出form表单,滚动条位置移到顶端,点击表单外时隐藏form表单。想要实现的效果,弹出form表单时滚动条位置不变
2020年03月16日 10点03分
5
js也能实现呀……
2020年03月16日 10点03分
level 8
你这个写法较为罕见,在“if isset”之前套一层div,并指定一个id,然后再对应的if 结束位置之后加上对应的</div>标签。
然后再参考我1楼说的话操作
你这样做是为了反垃圾评论吗?我认为你其实需要搭配一个验证码模块
2020年03月16日 10点03分
7
加div不行,我去试下js
2020年03月16日 10点03分
@lkkl2046 js方面比较弱,所以一开始不想从这方面入手
2020年03月16日 10点03分
@lkkl2046 但这种小逻辑确实不是PHP能实现的(因为太麻烦)
2020年03月16日 10点03分
@周存存 开启自学js之旅
2020年03月16日 10点03分