js simulate user touch event

The following code will automatically click on page element a to jump to the Bing search page

There are two methods in it.
I use self-executing function without onload

  1. js native
  2. jq adds a span node to a to simulate click jump
  (function () {
    document.write("<a href='https://cn.bing.com/'> <span id='p'> fjkaj</span></a>");
    // 1.
    document.querySelector("#p").click()
    // 2. 
    $("#p").click()
  }())
    // 这里记录下 自动修改input 属性值并 模拟搜索的jq脚本
    $(".b_searchbox").setAttribute("value", "aa=1111");
    $(".b_searchboxSubmit").click();

Guess you like

Origin www.cnblogs.com/lambertlt/p/12674469.html