In jQuery trigger ('click') and press () only seem to fire the onclick event. I want to simulate a tag click without an onclick event.
What I'm trying to achieve is to display the lightbox on landing. A lightbox is attached to a tag to be clicked.
Any ideas?
still to answer your original question, at least regarding mootools: you can simulate a click / fire set by a function to handle it (if any):
$("someid").fireEvent("click");
onclick - , . , .
onclick
-, . return false;, e.preventDefault(), , e.stopPropagation() e.stopImmediatePropagation(), .
return false;
e.preventDefault()
e.stopPropagation()
e.stopImmediatePropagation()
, lightbox "" .
//I use, when want show image in lightbox by original image or thumbnails list //simulate click on lightbox image by click another place with same image url (hack pro kliknuti na spravne url lightboxu) $('#simulate_click').click(function(event){ //get url from simulate link (zjistime url odkazu) var odkaz = $(this).attr("href"); //look for real lightbox link with the same url (najdeme lightbox odkaz) var lightOdkaz = $('#rc-carousel ul li a[href="'+odkaz+'"]'); //simulate clik on that lightbox link (klikneme na nej) lightOdkaz.trigger("click"); //stop propagation of click on original link (zabranime propagaci) return false; //event.stopPropagation(); });
:
window.location = $('a#go').attr('href')
. Slimbox mootools .
JavaScript, . Slimbox , !
Source: https://habr.com/ru/post/1721312/More articles:класс для синтаксического анализатора.. так же, как класс Regex для регулярных выражений - c#XPath syntax in XAML binding - xpathHigh bounce rate (99%) when installing two Google Analytics trackers - google-analyticsHow to get all action names from a controller - asp.net-mvcHow to determine local timestamp time for different time zones? - javascriptRowcount SQL table differs from Select Count in SQL Server - sqlCan Scrum and Project Management live together? - scrumStrange Apple Push Notification behavior when disconnecting host iPhone - iphoneto set permissions for files in the header before force loading in php? - phpCommon django templates - pythonAll Articles