Miscellaneous

get(index)

Retrieve one of the elements matched by the aQuery object.

index
Type: int
A zero-based integer indicating which element to retrieve.

Example

$(‘div’).show().get(0).style.height =100px’;

open(url [, target])

The open() method navigates to a url in the current window or opens a new tab.

url
Type: string
Specifies the URL of the page to open: 0
target
Type: string
Default: _top

Limitations in AMP:

  1. location.href is not allowed, use $(window).open() instead.
  2. Url can be either a hardcoded string or the value parameter from an event. it’s not possible to combine them. Example:
  • $(‘select’).on(‘change’, e => window.open(‘https://example.com’)) //this is allowed
  • $(‘select’).on(‘change’, e => window.open(e.value)) //this is allowed
  • $(‘select’).on(‘change’, e => window.open(‘https://example.com?q=’ + e.value)) //this is NOT allowed
  1. Only _top and _blank are allowed as target.

Example

//navigate to url on select change
$(‘select’).on(‘click’, (e) => {
$(window).open(e.value);
});