-1
我在這裏有我的問題video。向上箭頭點擊後數字增加,但反之亦然。我認爲jQuery代碼是不正確的。我以爲我只是從頂部到底部,並從+1到-1,但我錯了,它不能很好地工作。點擊向下箭頭後數字不會減少
代碼:
<?php
include("mwcon.php");
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href='/css/post.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
$(".post-vote-top").click(function() {
$(this).next(".post-vote-middle").text(function(i, v) {
return parseInt(v, 10)+1;
});
});
});
$(document).ready(function() {
$(".post-vote-bottom").click(function() {
$(this).next(".post-vote-middle").text(function(i, v) {
return parseInt(v, 10)-1;
});
});
});
</script>
</head>
<body>
<?php
echo "
<div id='post'>
<table>
";
$no=1;
$q=mysql_query("SELECT * FROM t_post");
while($f=mysql_fetch_object($q)){
echo "
<tr>
<td class='post-nomor'>$no.</td>
<td class='post-vote' align='center'>
<div id='main'>
<div class='post-vote-top'></div>
<div class='post-vote-middle'>$f->vote</div>
<div class='post-vote-bottom'></div>
</div>
</td>
<td><a href='$url' target='_blank'><img src='$f->linkimg' width='80' height='50'></img></a></td>
</tr>
";
$no++;
}
echo "
</table>
</div>
";
?>
</body>
</html>
請幫助我。謝謝。
我很慚愧你@balan。我很抱歉,我是jquery的新手。我根本沒有任何老師。它現在運作良好。也許在接下來的幾個小時裏,我會再問你一次。 –
@Junaserbaserbi:很高興幫助:) –
Pranav,請再次幫我在[這裏](http://stackoverflow.com/questions/33669459/confusing-about-this-cookies-in-redirecting-system) –