即时尝试将此jQuery脚本转换为切换事件类型,他们是我的脚本,插图,以显示我想要发生的事情。我CNT似乎所以这里intrgate有云:jQuery的问题?
//myElement.toggle(vote(), unvote()); // this is the toggle event
$(document).ready(function() {
$('.statuses').delegate('.vote_up', 'click', function(e) {
//stop event
e.preventDefault();
//get the id
var the_id = $(this).closest('.message').attr('id').split('_').pop();
//function vote() // this should be the vote up function
//the main ajax request
$.ajax({
context: this,
type: "POST",
// Make sure "this" in the callback refers to the element clicked
data: "action=vote_up&id=" + the_id,
url: "ajax/votes.php",
success: function (msg) {
$(this).siblings("span.vote_count").html(msg).fadeIn();
// get the child <img> and set its src
$(this).children("img").attr("src", "img/uparrowActive.png");
}
});
//function unvote() thier should be another function here to unvote toggle
$.ajax({
context: this,
type: "POST",
// Make sure "this" in the callback refers to the element clicked
data: "action=vote_down&id=" + the_id,
url: "ajax/votes.php",
success: function (msg) {
$(this).siblings("span.vote_count").html(msg).fadeIn();
// get the child <img> and set its src
$(this).children("img").attr("src", "img/uparrow.png");
}
});
});
我只是不知道如何将这种触发事件融入这个jQuery的片段,有人请帮助我我一直都努力了多年:))感谢
你错过了一个结束括号。你的'代表'结束了什么? – Incognito 2010-10-12 20:21:21
谢谢@user它不是关于语法现在,即时通讯只是想知道如何即将intergate这两个切换功能,我不是sem了解他们如何能适应,我即将如此新到这 – getaway 2010-10-12 20:26:44