Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery编写文本效果_Javascript_Jquery_Asp.net - Fatal编程技术网

Javascript 使用jquery编写文本效果

Javascript 使用jquery编写文本效果,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我正在使用此代码编写文本效果: <script type="text/javascript"> $(document).ready(function () { function changeText(cont1, cont2, speed) { var Otext = cont1.text(); var Ocontent = Otext.split(""); var i =

我正在使用此代码编写文本效果:

        <script type="text/javascript">
    $(document).ready(function () {
        function changeText(cont1, cont2, speed) {
            var Otext = cont1.text();
            var Ocontent = Otext.split("");
            var i = 0;
            function show() {
                if (i < Ocontent.length) {
                    cont2.append(Ocontent[i]);
                    i = i + 1;
                };
            };
            var Otimer = setInterval(show, speed);
        };
        $(document).ready(function () {
            changeText($("#TypeEffect p"), $(".p2"), 150);
        });
    });
</script>
因此,它不起作用

请帮我写多行文字效果。

试试看

$(document).ready(function () {
    function changeText(cont1, cont2, speed) {
        var contents = $(cont1).contents().map(function () {
            if (this.nodeType == 3) {
                if ($.trim(this.nodeValue).length) {
                    return this.nodeValue.split("")
                }
            } else {
                return $(this).clone().get();
            }
        }).get();
        var i = 0;

        function show() {
            if (i < contents.length) {
                cont2.append(contents[i]);
                i = i + 1;
            } else {
                clearInterval(Otimer)
            }
        };
        var Otimer = setInterval(show, speed);
    };
    $(document).ready(function () {
        changeText($("#TypeEffect p"), $(".p2"), 150);
    });
});
$(文档).ready(函数(){
功能更改文本(cont1、cont2、速度){
var contents=$(cont1).contents().map(函数(){
if(this.nodeType==3){
if($.trim(this.nodeValue).length){
返回此.nodeValue.split(“”)
}
}否则{
返回$(this.clone().get();
}
}).get();
var i=0;
函数show(){
如果(i
演示:

试试这个:

$(“[class*=autoWrite]”。每个函数(e){
autoWriteText($(此));
})
函数autoWriteText(elm){
var clas=elm.attr(“类别”);
类别=类别拆分(“-”);
var速度=clas[1];
var延迟=clas[2];
var txt=elm.html();
html(“”);
setTimeout(函数(){
埃尔姆·法登(“快速”);
txt=txt.split(“”);
var-txtI=0;
var html=“”;
var intrvl=setInterval(函数(){
html=html+txt[txtI];
html(html+“”);
txtI=txtI+1;
if(txtI==txt.length){
清除间隔(intrvl);
}
},速度);
},延误)
}
.autoWriteText{
显示:无;
}

此元素将在此框中每隔10毫秒写入一封信,延迟为0毫秒。

此元素将在此框中每隔50毫秒写入一个字母,延迟1秒。
此元素将在此框中每隔200毫秒写入一个字母,延迟为3秒。
此元素将在此框中每隔500毫秒写入一个字母,延迟为5秒。

看起来不错@ArunPJohny:它不是为多行编写的:使用:一些内容
一些内容

试试看
$(document).ready(function () {
    function changeText(cont1, cont2, speed) {
        var contents = $(cont1).contents().map(function () {
            if (this.nodeType == 3) {
                if ($.trim(this.nodeValue).length) {
                    return this.nodeValue.split("")
                }
            } else {
                return $(this).clone().get();
            }
        }).get();
        var i = 0;

        function show() {
            if (i < contents.length) {
                cont2.append(contents[i]);
                i = i + 1;
            } else {
                clearInterval(Otimer)
            }
        };
        var Otimer = setInterval(show, speed);
    };
    $(document).ready(function () {
        changeText($("#TypeEffect p"), $(".p2"), 150);
    });
});