I thought jQuery click()could allow us to add a handler or just click an element?
click()
However, I tried:
$(function() { setTimeout(function() { $('a').first().trigger('click'); // or click(), the same }, 3000); });
and waited 3 seconds and he wonβt click on the first element <a>on the page ... how?
<a>
Update: this is due to What is the best way to make autoplay of the Yahoo, jQuery media player? , and therefore be an event handler for clicking on the media, as it turned out .click(), which coincides with trigger('click'), and not disabling, this event handler?
.click()
trigger('click')
click() . click() (). , . , .
. , , "click" jquery. , , <button></button>, .click() , .
<button></button>
"" , , . , href - javascript, ( ):
var lnk = $('a.mylink'); window.location = lnk.attr('href');
, .first() - .
.first()
$('a:first').click();
? .first() , , .click() , , ( ).
, ( ):
location.href = $('a').first().get(0).href;
, trigger():
trigger()
$('a:first').trigger('click');
? . , , - :
$(function() { setTimeout(function() { window.location.replace("linkToNewPage.html"); }, 3000); });
" . Plz check http://mediaplayer.yahoo.com/api/#example_usage u autoplay = true, .."
- Kai
:
Yahoo, jQuery?
Else for click attach the click handler to what you want, for example:
$('#MyElementID').click(function() { //How you want it to behave when you click it. }); window.setTimeout(YourFunction, 3000); function YourFunction { //Your function that runs. Maybe fire the onclick handler? }
?
You are trying to use a method click()for something other than its purpose. click()used so that you can catch a click on a specific element, and not to simulate.
More here
Source: https://habr.com/ru/post/1752035/More articles:Secure Web Service (NTLM) - Jmeter - authenticationRecord video in a webcam to a local file system from a browser - javaLink outside iframe - javascriptHow to customize skin type and type Product Type Bundle programmatically in Magento? - phpHow to get jQuery to accept json response? - jsonjQuery click () can only trigger event handlers for DOM 0 and event handlers registered through jQuery ...? - javascriptManaging Large Log Files - debuggingWhat is the best way to make autoplay of a Yahoo, jQuery media player? - javascriptCSS opacity playback - cssFlex expands ComboBox - flexAll Articles