最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Auto Click in HTML Button - Stack Overflow

programmeradmin4浏览0评论
<h1>Wele to My Page!</h1>
<h2>My name is Bob.</h2>
<h3>I hope you like it here.</h3>
<embed src="MY WEBSITE LINK" style="width:500px; height: 300px;">
<input type="checkbox" id="btd" onmouseover="myFunction()" onclick="alert('clicked')">

<script>
jQuery(function(){
   jQuery('#btd').click();
});
</script>

I have the code. But didn't Work.

How to Auto Click Button Continue, from Image?

<h1>Wele to My Page!</h1>
<h2>My name is Bob.</h2>
<h3>I hope you like it here.</h3>
<embed src="MY WEBSITE LINK" style="width:500px; height: 300px;">
<input type="checkbox" id="btd" onmouseover="myFunction()" onclick="alert('clicked')">

<script>
jQuery(function(){
   jQuery('#btd').click();
});
</script>

I have the code. But didn't Work. http://www.imagebam./image/31ac1b820717083

How to Auto Click Button Continue, from Image?

Share Improve this question edited May 24, 2018 at 4:56 Vadim Kotov 8,2848 gold badges50 silver badges63 bronze badges asked Apr 14, 2018 at 6:12 user7775547user7775547 2
  • 2 It is unclear what you're asking. Your HTML code does not contain a button. It is unclear how this relates to the code shown in the image. – Philip Commented Apr 14, 2018 at 6:16
  • imagebam./image/31ac1b820717083 – user7775547 Commented Apr 14, 2018 at 6:24
Add a ment  | 

2 Answers 2

Reset to default 4

We can't do auto click in HTML, but we can call any function that the button does with Jquery. To work Jquery code, you want to add this to your code

<script src="https://code.jquery./jquery-3.2.1.min.js"></script>

Actually when we click any button, it calls a function, that may be our own function or built in one. Here Javascript can easily call any function without any button Like this

//define the function

function alertsomething(){
  alert("Hey, This is an alert inside that function");
}

//function works when button clicks 
$("#btd").click(function(){
  alertsomething();
})

//function automatically when page loads
$(document).ready(function(){
  alertsomething();
})
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="btd" >Click me</button>

Here are the two ways to call a function. One is when you click the button and another one is when your page loads, that function will call automatically...

Thanks

<script> setInterval(function(){  document.getElementById('btn').click() }, 10000); </script>

Its working script for me Send "data" from FORM 'POST' to refresh HTML page whith PHP code

发布评论

评论列表(0)

  1. 暂无评论