Query < Page

With AwesomeQuery, the Page object has been given a Query function similar to the default jQuery $() function. Providing a CSS style selector as a string, the user can select a set of elements as an array to be searched through or modified in a single operation. More on CSS selectors can be found here.


Keep in mind, the Query function will not provide functions that jQuery provides, however, you can call common functions or retrieve properties of all the elements from the query as an array itself. Below is a simple example:

Page.OnLoad.Add(function () {
        Page.Query("a").ForEach(function (a) {


This will select all the anchors on the page and set the background color of each to the color orange.

Using the As function

A shorthand way of treating all the objects in an array (including arrays created with the Query function) is to use the As function. As lets you pass in a type that Awesome will attempt to treat each item as. You have to guarantee that each object will be of the same type, else you may run into runtime issues. Here is the same code above using the As function:

Page.OnLoad.Add(function () {

Last edited Sep 18, 2011 at 1:57 AM by dahrkdaiz, version 4


No comments yet.