10 examples of 'jquery trigger click on link' in JavaScript

Every line of 'jquery trigger click on link' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
16export function applyInPageLink(elTrigger) {
17 const elId = elTrigger.getAttribute('href').replace('#', '')
18 elTrigger.addEventListener('click', (e) => {
19 e.preventDefault()
20 focusOnInput(elId)
21 })
22
23 return { elTrigger, elId }
24}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

69debugMenuLinks.click( function onClickLink( event ) {
70 var $this = $( this );
71
72 event.preventDefault();
73
74 if ( $this.hasClass( 'current' ) ) {
75 return;
76 }
77
78 // Deselect other tabs and hide other panels.
79 debugMenuTargets.hide().trigger( 'debug-bar-hide' );
80 debugMenuLinks.removeClass( 'current' );
81
82 // Select the current tab and show the current panel.
83 $this.addClass( 'current' );
84 // The hashed component of the href is the id that we want to display.
85 $( '#' + this.href.substr( this.href.indexOf( '#' ) + 1 ) ).show().trigger( 'debug-bar-show' );
86} );
83link(e, target) {
84 const he = this.linkables.find(he => he.id === e.target.id)
85 if (!he) {
86 return
87 }
88 this.dispatchEvent(new CustomEvent('link-to-health-element', {bubbles: true, composed: true, detail: {representedObject: this.representedObject, healthElement: he}}))
89}
279function blockLinksOnClick (event) {
280 if (
281 event.target.nodeName === 'A' &&
282 event.target.getAttribute('href').indexOf('http') === 0
283 ) {
284 event.preventDefault()
285 }
286}
32function anchorLink(linkTarget) {
33 const target = $( "#" + linkTarget );
34 // Find the targeted element to expand and all its parents that can be expanded
35 target.parents().addBack().filter(".collapse:not(.show), .tab-pane, [role='tab']").each(
36 function(index) {
37 if($( this ).hasClass("collapse")) {
38 $( this ).collapse("show");
39 } else if ($( this ).hasClass("tab-pane")) {
40 // We have the pane and not the the tab itself, find the tab
41 const tabToShow = $( "a[href='#" + $( this ).attr("id") + "']" );
42 if (tabToShow) {
43 tabToShow.tab("show");
44 }
45 } else if ($( this ).attr("role") === "tab") {
46 // The tab is not a parent of underlying elements, the tab pane is
47 // However, it can still be linked directly
48 $( this ).tab("show");
49 }
50 }
51 );
52
53 // Wait a little so the user has time to see the page scroll
54 // Or maybe it is to be sure everything is expanded before scrolling and I was not able to bind to the bootstrap
55 // events in a way that works all the time, we may never know
56 setTimeout(function() {
57 let targetElement = document.getElementById(linkTarget);
58 if (targetElement) {
59 targetElement.scrollIntoView({ block: "center", behavior:"smooth" });
60 // Flash the element so that the user notices where the link points to
61 setTimeout(function() {
62 flashElement(linkTarget);
63 }, 500);
64 }
65 }, 1000);
66}
415function interceptPulldownLink(event) {
416 var menu = $(this).closest('.pull-menu');
417 menu.popover('destroy').
418 popover({placement:"bottom",
419 html:true,
420 content:menu.children('ul').html(),
421 trigger:"manual",
422 delay:1500,
423 template: '<div class="popover" onmouseover="$(this).mouseleave(function() {$(this).fadeOut(); });"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
424
425 }).click(function(e) {
426 e.preventDefault() ;
427 }).popover('show');
428
429 event.preventDefault();
430 event.stopPropagation();
431}
22function handleClick(event: React.MouseEvent<any>, context: RouteComponentProps) {
23 if (p.onClick)
24 p.onClick(event)
25
26 if (
27 !event.defaultPrevented && // onClick prevented default
28 event.button === 0 && // ignore everything but left clicks
29 !p.target && // let browser handle "target=_blank" etc.
30 !isModifiedEvent(event) // ignore clicks with modifier keys
31 ) {
32 event.preventDefault()
33
34 const history = context.history
35 const { replace, to } = p
36
37 if (replace) {
38 history.replace(to as string)
39 } else {
40 history.push(to as string)
41 }
42 }
43}
24function linkHandler( ev ) {
25 var href;
26 ev.preventDefault();
27 if ( url !== undefined ) {
28 href = url;
29 } else {
30 href = $( this ).attr( 'href' );
31 }
32 log( status, campaign, step ).always( function () {
33 window.location.href = href;
34 } );
35}
26triggerClick() {
27 this.onClickCallbacks.forEach(callback => callback());
28}
77clickHandler(evt) {
78 const { onClick, target } = this.props
79
80 if (onClick) {
81 onClick(evt)
82
83 if (evt.defaultPrevented) {
84 return
85 }
86 }
87
88 const comboKey =
89 evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey
90
91 if (evt.button === 0 && !comboKey && target !== '_blank') {
92 evt.preventDefault()
93 this.router.navigate(
94 this.props.routeName,
95 this.props.routeParams || {},
96 this.props.routeOptions || {},
97 this.callback
98 )
99 }
100}

Related snippets