自己改了一点$.extend() 不知道为什么不好用
<!DOCTYPE html>
<html>
<head>
<title>使用$.extend()扩展工具函数</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://www.imooc.com/data/jquery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">自定义工具函数求两值中最小值</span>
<span class="fr">
<input type="text" id="num1" />
<input type="text" id="num2" />
<input id="btnShow" name="btnShow" type="button" value="计算" />
</span>
</div>
<div class="content">
<div class="tip"></div>
</div>
</div>
<script type="text/javascript">
/*------------------------------------------------------------/
功能:返回两个数中最小值
/------------------------------------------------------------*/
(function ($) {
$.extend({
"MinNum": function (p1, p2) {
return (p1 > p2) ? p2 : p1;
}
});
})(jQuery);
$(function () {
$("#btnShow").bind("click", function () {
$(".tip").html("");
var strTmp = "最小的数是:";
var num1=$('#num1').val();
var num2=$('#num2').val();
strTmp += $.MinNum(num1, num2);
//显示在页面中
$(".tip").show().append(strTmp);
});
});
</script>
</body>
</html>显示的永远是num1的数 老哥们帮我看看哪里出问题了