生活在远方

是的,因为真正的生活是在远方

【jQuery】示例5:一个简单的投票系统

Written By: tr - May• 10•09

今天抽空完成了jQuery的示例5:一个简单的投票系统

本例没有什么特殊的地方。只有一点。投票系统至少需要两个参数:一个是投票项目的id,一个是投票的方向(支持还是反对),所以我这样构造一个a元素:

<a href='#' class='up' id='<?php echo $row['vid']?>'><?php echo $row['up']?></a>

我用class来确定投票方向,而用id来确定投票项目。

最后,我用jQuery中的replaceWith来替代掉被点击的a元素的内容为:

$(this).replaceWith("<strong>"+count+"</strong>");

大功告成!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">