Question: I would like to know how to declare a variable in jQuery

The code I am currently using is

```
$.name = 'anirudha';
alert($.name);

```

That code works fine, but if I write it as

```
$.name = document.myForm.txtname.value;
alert($.name);

```

Then my code does not work.

Answer: 
Try this : 

```
var name = $("#txtname").val();
alert(name);

```
in jquery we have to use selector($) to declare variables

```
var test=$("<%=ddl.ClientId%>");

```

here we can get the id of drop down to [j query variable](http://csharpektroncmssql.blogspot.com/2012/01/jquery-and-how-to-declare-variables.html)