的jQuery:jQuery的:更改图片src和一流的onclick
$(".upvote").click(function() {
var id = $(this).attr('id');
var changeImage = ($(this).children('img').attr('src') === siteUrl + '/images/icon-upvote.png')
? siteUrl + '/images/icon-upvote-inactive.png'
: siteUrl + '/images/icon-upvote.png';
$(this).children('img').attr('src', changeImage);
var changeClass = ($(this).children('img').attr('src') === siteUrl + '/images/icon-upvote.png')
? 'vote-icon'
: 'vote-icon semi-transparent-more';
$(this).children('img').attr('class', changeClass);
$.ajax({
type: 'GET',
data: 'comic=' + id + '&type=upvote',
url: siteUrl + '/vote.php',
success: function() {
// PHP does all checks
}
});
});
HTML:
<div>
<a href="vote.php?comic=$fileName&type=upvote" id="$fileName" class="upvote$guestLink" onclick="return false;">$upvoteImage</a>
</div>
<div style="margin: 5px 0 8px 0;">
<span class="score$scoreStyle bold" id="$fileName">$fileScore</span>
</div>
<div>
<a href="vote.php?comic=$fileName&type=downvote" class="downvote$guestLink">$downvoteImage</a>
</div>
这是我已经有了和它的作品真的很好。问题是我知道有一种方法可以让我的效率比我的效率高一点。
另外,如何选择该跨度以更改其值?我将如何根据目前设置的内容调整价值?我一直在这个问题上苦苦挣扎,时间最长。
我建议你在帖子的开头写下你的问题。在知道要寻找什么之前,必须通读30行代码才能让某些人失望。 – 2012-01-01 01:58:10