Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trigger click event with css selector in prototype

I am new in Prototype js. I have an element like this,

<li id="toolbar-save" class="button">
  <a class="toolbar"  href="www.mydomain.com/register">
     Save &amp; Close
  </a>
</li>

I have a selector for the anchor tag, $$('#toolbar-save a'). By using this selector how can I trigger the click event ? or any other way you can suggest ? thanks in advance.

like image 410
Nisam Avatar asked Jun 13 '13 21:06

Nisam


People also ask

How do you trigger a click element?

The HTMLElement. click() method simulates a mouse click on an element. When click() is used with supported elements (such as an <input> ), it fires the element's click event. This event then bubbles up to elements higher in the document tree (or event chain) and fires their click events.

How do I trigger a click event without clicking?

If you want native JS to trigger click event without clicking then use the element id and click() method of JavaScript.

How do I use matches CSS selector in GTM?

If click on the link while in GTM preview mode and check out the Click Element in the preview console, you'll notice that it is listed as an object in the Data Layer. Since it's a Data Layer object, we can dig a little deeper in the element using our Developer Tools to find a CSS selector.

Which variable does the matches CSS selector trigger predicate best work with?

You can use the matches CSS selector trigger predicate together with the Click Element variable to check if the element matches a specific selector (d'oh).


1 Answers

$$('#toolbar-save a')[0].click();

FIDDLE

like image 53
adeneo Avatar answered Sep 17 '22 18:09

adeneo