# Query

> Initializes a QueryBuilder with the specified selection rules.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.UIElements](/engine/6000.6/script-reference/unityengine/uielements.md)
* **Assembly:** UnityEngine.UIElementsModule

## Query(VisualElement, string, string\[])

Initializes a QueryBuilder with the specified selection rules.

```csharp
public static UQueryBuilder<VisualElement> Query(this VisualElement e, string name = null, params string[] classes)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.6/script-reference/unityengine/uielements/visualelement)): Root VisualElement on which the selector will be applied.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If specified, will select elements with this name. The default value is `null`.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): If provided, it selects elements with all the specified classes (case sensitive, to be distinguished from Type).

### Returns

| Type                                                                                                      | Description                                                  |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [UQueryBuilder\<VisualElement>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) | QueryBuilder configured with the associated selection rules. |

## Query(VisualElement, string, string)

Initializes a QueryBuilder with the specified selection rules.

```csharp
public static UQueryBuilder<VisualElement> Query(this VisualElement e, string name = null, string className = null)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.6/script-reference/unityengine/uielements/visualelement)): Root VisualElement on which the selector will be applied.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If specified, will select elements with this name. The default value is `null`.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If provided, it selects elements with the specified class (case sensitive, to be distinguished from Type). The default value is `null`.

### Returns

| Type                                                                                                      | Description                                                  |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [UQueryBuilder\<VisualElement>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) | QueryBuilder configured with the associated selection rules. |

## Query\<T>(VisualElement, string, string\[])

Initializes a QueryBuilder with the specified selection rules.

```csharp
public static UQueryBuilder<T> Query<T>(this VisualElement e, string name = null, params string[] classes) where T : VisualElement
```

### Parameters

**** (\[VisualElement]\(/engine/6000.6/script-reference/unityengine/uielements/visualelement)): Root VisualElement on which the selector will be applied.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If specified, will select elements with this name. The default value is `null`.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): If provided, it selects elements with all the specified classes (case sensitive, to be distinguished from Type).

### Returns

| Type                                                                                          | Description                                                  |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) | QueryBuilder configured with the associated selection rules. |

## Query\<T>(VisualElement, string, string)

Initializes a QueryBuilder with the specified selection rules.

```csharp
public static UQueryBuilder<T> Query<T>(this VisualElement e, string name = null, string className = null) where T : VisualElement
```

### Parameters

**** (\[VisualElement]\(/engine/6000.6/script-reference/unityengine/uielements/visualelement)): Root VisualElement on which the selector will be applied.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If specified, will select elements with this name. The default value is `null`.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): If provided, it selects elements with the specified class (case sensitive, to be distinguished from Type). The default value is `null`.

### Returns

| Type                                                                                          | Description                                                  |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) | QueryBuilder configured with the associated selection rules. |

## Query(VisualElement)

Initializes a QueryBuilder with the specified selection rules.

```csharp
public static UQueryBuilder<VisualElement> Query(this VisualElement e)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.6/script-reference/unityengine/uielements/visualelement)): Root VisualElement on which the selector will be applied.

### Returns

| Type                                                                                                      | Description                                                  |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [UQueryBuilder\<VisualElement>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) | QueryBuilder configured with the associated selection rules. |
