使用jQuery或纯javascript在Instagram帖子上提交评论

使用jQuery或纯javascript在Instagram帖子上提交评论,javascript,jquery,html,triggers,keypress,Javascript,Jquery,Html,Triggers,Keypress,我需要使用javascript或jQuery在Instagram帖子上提交评论,因此我使用: $('input[placeholder="Add a comment…"]').val('MY COMMENT'); 此代码填充instagram和post页面的注释文本框,如下所示: 我需要的最后一件事是触发“回车”按钮。 我尝试了在stackoverflow上找到的以下代码,但没有成功: (一) 2) 为了确定选择器,我将文本颜色更改为红色,并且选择器被正确选择 $('input[placeh

我需要使用javascript或jQuery在Instagram帖子上提交评论,因此我使用:

$('input[placeholder="Add a comment…"]').val('MY COMMENT');
此代码填充instagram和post页面的注释文本框,如下所示:

我需要的最后一件事是触发“回车”按钮。 我尝试了在stackoverflow上找到的以下代码,但没有成功:

(一)

2) 为了确定选择器,我将文本颜色更改为红色,并且选择器被正确选择

$('input[placeholder="Add a comment…"]').val('MY COMMENT');
var e = jQuery.Event("keypress");
e.which = 13; //choose the one you want
e.keyCode = 13;
$("input").first().css('color','red').trigger(e);
我认为这种触发“回车”键的方式不合适,有没有其他方法可以像在键盘上按一样触发“回车”键


任何帮助都将不胜感激。

我找到了解决方案,但这并不像@SalmanShariati在评论中所说的那样

在父窗体上触发submit事件,而不是在textarea上触发KeyBoardEvent

var form = document.querySelector("form"); // that is the only form on the page
form.dispatchEvent(new Event("submit")); // make sure to change the value of the textarea to your required comment before doing this

这对我很有用。

你明白了吗?我更改了解决方案并使用了http RequestsSalman,你能写出解决方案吗?@SalmanShariati你能写出你的答案吗?我目前正试图正确地发送请求:)@salmansharati你能告诉我们你的解决方案吗
var form = document.querySelector("form"); // that is the only form on the page
form.dispatchEvent(new Event("submit")); // make sure to change the value of the textarea to your required comment before doing this