$$

This method retrieves a jQuery object by:

  • Raw ID value
  • Any ID that ends in _{id}

It's highly useful in Web Control Framework applications where you can lookup nested controls that may have a control prefix like ctl00_MainContent_txtSymbol where you can just use $$("txtSymbol") to find the element.

$$(id,context)

Return Value

jQuery object (same as $()). Check length > 0 to see if matches exist.

Parameters

id
The id of the element to search for. Matches exact ID or anything that ends in _{id}.

context
The parent context where searches start from. Use this optimize searches for controls to a specific parent container. If omitted the entire document is searched. Can be a jQuery or DOM object.

Remarks

Depends on jQuery.

This method has some overhead if the ID is a partial ID and it's nested deeply in the document as the entire document tree has to be traversed by jQuery to find the element and search for the ID explicitly.

Example

<input id="ctl00_MainContent_txtSymbol" value="MSFT" />

<script>
console.log( $$("txtSymbol").attr("id") );  // ctl00_MainContent_txtSymbol
</script>

© West Wind Technologies, 1996-2024 • Updated: 08/24/19
Comment or report problem with topic