<link type="text/css" rel="stylesheet" href="css/style.css"> <div class="flex_container">
<h3>请输入字母查看效果</h3>
<form>
<div class="input_wrap">
<input type="text" placeholder="英文字母大写或小写" />
<div class="after"></div>
</div>
</form>
</div> <script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
(function($) {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$.fn.animChars = function(options) {
var params = $.extend(
{
duration: 1,
upperLimit: 150,
sizeInterval: [15, 80]
},
options
);
$(this).keypress(function(e) {
//console.log(this.selectionStart)
var rand = getRandomInt(1, 9);
var randP = Math.floor(Math.random() * 10);
randP < 5 ? (randP = rand) : (randP = rand - rand * 2);
var c = String.fromCharCode(e.which);
//console.log(c);
if (c.charCodeAt(0) <= 90 && c == c.toUpperCase()){//charCodeAt(0) > 96 为小写 charCodeAt(0) <= 90 为大写
c = c.toUpperCase();
}else{
c = c.toLowerCase();
}
$(this).parent().append("<span class='cl" + rand + "'>" + c + "</span>");
$(this)
.parent()
.find("span.cl" + rand + "")
.css({
left: getRandomInt(0, 90) + "%",
"font-size": getRandomInt(
params.sizeInterval[0],
params.sizeInterval[1]
)
})
.fadeIn(100, function() {
$(this)
.css({
"margin-bottom": getRandomInt(
params.upperLimit - params.upperLimit / 2
? params.upperLimit / 2
: 0,
params.upperLimit
),
"margin-left": randP * 10
})
.fadeOut(params.duration * 1000, function() {
$(this).remove();
});
});
});
};
})(jQuery);
$(document).ready(function() {
$("input").animChars({
duration: 0.8,
upperLimit: 200,
sizeInterval: [15, 80]
});
});
</script>
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
