如何使用jQuery在我的网站演示中自动填写表单,好像真人正在打字?

时间:2023-01-13 09:50:01

I have a website with registration forms. I'm going to be demoing the website onscreen, and would like to have the forms fill themselves out, as if a person was manually typing in the form data.

我有一个注册表格的网站。我将在屏幕上演示网站,并希望将表单填满,就像一个人手动输入表单数据一样。

Is there a relatively simple way to do this with jQuery?

使用jQuery有一个相对简单的方法吗?

Thanks very much!

非常感谢!

4 个解决方案

#1


1  

From this Stack Overflow question, it looks like there’s a jQuery plug-in called jTypeWriter that might do what you’re looking for.

从这个Stack Overflow问题来看,它看起来像是一个名为jTypeWriter的jQuery插件,它可能正在寻找你正在寻找的东西。

But as Robert says, the Selenium IDE plug-in for Firefox lets you record and play back browser interactions — assuming you’re demoing from your own computer, that’s probably easier than writing a bunch of jQuery code.

但正如罗伯特所说,用于Firefox的Selenium IDE插件可以让你录制和播放浏览器交互 - 假设你是从你自己的计算机进行演示,这可能比编写一堆jQuery代码更容易。

#2


4  

I would instead look at the Selenium IDE.

我会改为查看Selenium IDE。

#3


3  

Here is a simple solution:

这是一个简单的解决方案:

//declare string to write,
//then split it at each letter,
//then get the total number of letters,
//declare a starting index of zero,
//then set a timer for an interval
var string  = 'hello there',
    letters = string.split(''),
    total   = letters.length,
    index   = 0,
    $ele    = $('input'),//this should be changed to target the form input you want to type into
    timer   = setInterval(function () {

        //check if there are any more letters
        if (index < total) {

            //if there are more letters then add the next letter to the input
            $ele.val(function () {
                return $ele.val() + letters[(index++)];
            });

        //if there are no more letters then clear the interval so it stops running
        } else {
            clearInterval(timer);
        }
    }, 500);

Here is a demo: http://jsfiddle.net/pCVE6/

这是一个演示:http://jsfiddle.net/pCVE6/

#4


1  

What about a Macro PlugIn?
If you use Firefox, you can check out this: iMacros.

宏插件怎么样?如果您使用Firefox,可以查看:iMacros。

#1


1  

From this Stack Overflow question, it looks like there’s a jQuery plug-in called jTypeWriter that might do what you’re looking for.

从这个Stack Overflow问题来看,它看起来像是一个名为jTypeWriter的jQuery插件,它可能正在寻找你正在寻找的东西。

But as Robert says, the Selenium IDE plug-in for Firefox lets you record and play back browser interactions — assuming you’re demoing from your own computer, that’s probably easier than writing a bunch of jQuery code.

但正如罗伯特所说,用于Firefox的Selenium IDE插件可以让你录制和播放浏览器交互 - 假设你是从你自己的计算机进行演示,这可能比编写一堆jQuery代码更容易。

#2


4  

I would instead look at the Selenium IDE.

我会改为查看Selenium IDE。

#3


3  

Here is a simple solution:

这是一个简单的解决方案:

//declare string to write,
//then split it at each letter,
//then get the total number of letters,
//declare a starting index of zero,
//then set a timer for an interval
var string  = 'hello there',
    letters = string.split(''),
    total   = letters.length,
    index   = 0,
    $ele    = $('input'),//this should be changed to target the form input you want to type into
    timer   = setInterval(function () {

        //check if there are any more letters
        if (index < total) {

            //if there are more letters then add the next letter to the input
            $ele.val(function () {
                return $ele.val() + letters[(index++)];
            });

        //if there are no more letters then clear the interval so it stops running
        } else {
            clearInterval(timer);
        }
    }, 500);

Here is a demo: http://jsfiddle.net/pCVE6/

这是一个演示:http://jsfiddle.net/pCVE6/

#4


1  

What about a Macro PlugIn?
If you use Firefox, you can check out this: iMacros.

宏插件怎么样?如果您使用Firefox,可以查看:iMacros。