jQuery的问题? [英] jquery problem?
本文介绍了jQuery的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几天来遇到的这个jquery问题,我对此很陌生,所以请原谅我在这个问题上的愚蠢.谢谢:))
i have this jquery problems i have had for days, im so new to this, so excuse my dumbness in this subject. thanks :))
html代码:
<ul class="statuses">
<li id="set_23" class="message">
// this is meant to increase everytime you click the vote_up just like stackoverflow
<span class="vote_count">27</span>
<a href="#" class="vote_up"><img src="img/uparrow.png" /></a>
<a href="#" class="vote_down"><img src="img/downarrow.png" /></a>
</li>
</ul>
这是我的jquery代码:
this is my jquery code:
$(document).ready(function() {
$('#statuses').delegate('.vote_up', 'click', function() {
//get the id
var the_id = $(this).closest('.message').attr('id').split('_').pop();
//the main ajax request
$.ajax({
type: "POST",
data: "action=vote_up&id=" + the_id,
url: "ajax/votes.php",
success: function (msg) {
// fade in the new vote_count
$(this).siblings("span.vote_count").html(msg).fadeIn();
// get the child <img> and set its src
$(this).children("img").attr("src", "img/uparrowActive.png");
}
});
});
});
jquery fade.in和图像src的更改也不起作用,我是否引用了正确的跨度或类(ajax请求现在正在起作用)
also the jquery fade.in and change of image src is not working, am i referencing the right span or class(the ajax request is working now)
推荐答案
要跳出来的第一件事:
<ul class="statuses">
和
$('#statuses')
... jQuery中的#符号是id选择器(与CSS相同).由于您的<ul>
设置为class="statuses"
,因此您需要使用类选择器:
... the # symbol in jQuery is the id-selector (same as CSS). Since your <ul>
is set to class="statuses"
then you'll need to use the class-selector:
$('.statuses')
仅此一项将破坏您的所有jQuery
That alone will break all your jQuery
这篇关于jQuery的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文