Anchor search attribute

Definition and usage

search Attribute setting or return href attribute value The query string part.

The query string is the part after the question mark (?) in the URL. It is usually used for parameter passing.

See also:

JavaScript Reference Manual:location.search attribute

Example

Example 1

Return the query string part of the link:

var x = document.getElementById("myAnchor").search;

Try it yourself

Example 2

Change the query string part of the link:

document.getElementById("myAnchor").search = "somenewsearchvalue";

Try it yourself

Syntax

Return the search attribute:

anchorObject.search

Set the search attribute:

anchorObject.search = querystring

Attribute Value

Value Description
querystring Specifies the search part of the URL.

Technical Details

Return Value: A string value representing the query string part of the URL, including the question mark (?).

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support