3

我正在尝试制作 facebook autoreply msg 脚本,这是我的代码

$(window).load(function(){
var a=setInterval(function(){
var e = $('.titlebarText').html();
if(!e)
{
}
else
{
$('textarea.uiTextareaAutogrow.input').focus().val('Test!');
var c = jQuery.Event("keydown");
c.which = 13; 
$('textarea.uiTextareaAutogrow.input').trigger(c);
}
}
,5000);
});


$(window).load(function(){
var q=setInterval(function(){
$('.close').click()}
,6000);
});

一切正常,但在专注于 textarea 并插入值后模拟输入..

4

1 回答 1

2

Your selector looks strange. textarea.uiTextareaAutogrow.input says "the textarea with class uiTextareaAutogrow and class input"--do you really have a textarea tag with the class input?

You could try this, provided your selector is correct:

var e = $.Event('keydown', { keyCode: 13 });
$('textarea.uiTextareaAutogrow.input').trigger(e);
于 2012-10-22T15:14:14.927 回答