jquery 函数“.textAnim”什么都不做 textTyping_animation(); 工作正常,但 .textAnim 不起作用。这是插件代码:
function textTyping_animation(text,location,speed){
var progress = 0;
var a = setInterval(function(){
progress++;
document.getElementById(location).innerHTML = text.substring(0,progress);
if(progress == text.length){
clearInterval(a);
}
},speed);
};
(function($){
$.fn.textAnim = function(text,speed){
var progress = 0;
var a = setInterval(function(){
progress++;
$(this).html(text.substring(0,progress));
if(progress == text.length){
clearInterval(a);
}
},speed);
};
})(jQuery);
这是执行:
$(document).ready(function(){
starttext = function()
{
document.getElementById("textbox").style.display = "block";
//textTyping_animation("Dit is een dummy text!","textbox_inner",70);
$("#textbox_inner").textAnim("Dit is een dummy text!",70);
}
});
html加载代码:
<script type="text/javascript" language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" language="javascript" src="js/jqueryplugins.js" ></script>
<script type="text/javascript" language="javascript" src="js/libraries/gamelibrary.js"></script>