Last active
August 29, 2015 13:58
-
-
Save alanerzhao/9947978 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style type="text/css"> | |
.numshow { | |
color:red; | |
z-index:120; | |
font-size:20px; | |
} | |
</style> | |
</head> | |
<body> | |
<button id="btn" data-num="1">111</button> | |
<script type="text/javascript" src="./learn/list/js/jquery.js"></script> | |
<script type="text/javascript"> | |
$.fn.UpNum = function(num, callback, b, c) { | |
return this.each(function() { | |
var h = $(this).offset(); | |
var m = Math.round(h.left) + "px"; | |
var k = Math.round(h.top) + "px"; | |
if (num.toString().indexOf("-") == 0) { | |
var n = Math.round(h.top) + 30 + "px" | |
} else { | |
var n = Math.round(h.top) - 30 + "px" | |
} | |
var g = "20px"; | |
if (b) { | |
g = b | |
} | |
c = c || "120"; | |
var l = num || $(this).attr("money"); | |
$("<div>").appendTo($("body")).addClass("numeric").css({ | |
position: "absolute", | |
top: k,left: m, | |
color: (num.toString().indexOf("-") == 0) ? "#333" : "red", | |
fontFamily: "Georgia", | |
fontSize: g, | |
zIndex: c | |
}).html(l).animate({ | |
top: n | |
}, {duration: 1000,complete: function() { | |
// $(this).remove(); | |
if (callback) { | |
callback() | |
} | |
}}) | |
}) | |
} | |
$(function () { | |
$("#btn").click(function () { | |
$(this).UpNum("+1",console.log("加1了")) | |
}) | |
}) | |
/*Ding = function(iid, num, thisid, obj) { | |
$(obj).blur(); | |
if (!$(obj).data("inited")) { | |
if ($(obj).closest(".float-bar").size() > 0) { | |
$("#float_topvote" + thisid).UpNum("+1", function() { | |
$("#float_topvote" + thisid).html(num + 1) | |
}) | |
} | |
$("#topvote" + thisid).UpNum("+1", function() { | |
$("#topvote" + thisid).html(num + 1) | |
}); | |
$.post("/group/ajax_infovote.php", {iid: iid}, function(d) { | |
if ("sina" == d.data.login || d.data.is_sina > 0) { | |
if ("function" == typeof (ginfo_ding_activities)) { | |
ginfo_ding_activities(iid, "sina", obj) | |
} | |
} | |
}, "json") | |
} | |
$(obj).data("inited", true) | |
};*/ | |
</script> | |
</body> | |
</html> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style type="text/css"> | |
.numshow { | |
color:red; | |
z-index:120; | |
font-size:20px; | |
font-family:"Georgia"; | |
position:absolute; | |
} | |
</style> | |
</head> | |
<body> | |
<button id="btn" data-num="3">111</button> | |
<script type="text/javascript" src="./learn/list/js/jquery.js"></script> | |
<script type="text/javascript"> | |
$.fn.numShow = function(num, callback) { | |
return this.each(function() { | |
var h = $(this).offset(), | |
m = Math.round(h.left) + "px", | |
k = Math.round(h.top) + "px", | |
tipCont = num || $(this).attr("data-num"); | |
if (num.toString().indexOf("-") == 0) { | |
//向上 | |
var n = Math.round(h.top) + 30 + "px" | |
} else { | |
//向下 | |
var n = Math.round(h.top) - 30 + "px" | |
} | |
$("<div>").appendTo($("body")).addClass("numshow").css({ | |
top: k, | |
left: m, | |
}).html(tipCont).animate({ | |
top: n | |
},{duration: 1000,complete: function() { | |
$(this).remove(); | |
if (callback) { | |
callback() | |
} | |
} | |
}) | |
}) | |
} | |
$(function () { | |
$("#btn").click(function () { | |
$(this).numShow("+10",console.log("加1了")) | |
}) | |
}) | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment