日期:2014-05-18 浏览次数:20492 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="JS/jquery-1.4.1.js" type="text/javascript"></script> </head> <body> <table> <tr> <td> <input type="hidden" value="0" id="count" /> <input type="button" value="增加" id="add" /> <input type="button" value="减少" id="reduce" /> </td> </tr> </table> <script type="text/javascript"> $("#add").bind("click", function () { $(this).after("<img src='Images/4.jpg'>"); var count = $("#count").val(); $("#count").val(parseInt(count) + 1); }); $("#reduce").bind("click", function () { if ($(this).prev("img")[0]) { var count = $("#count").val(); $("#count").val(parseInt(count) - 1); } $(this).prev("img").remove(); }); </script> </body> </html>