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: 
Here's are some examples:

```
var name = 'india';
alert(name);  

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

```

Taken from 
<http://way2finder.blogspot.in/2013/09/how-to-create-variable-in-jquery.html>
```
var name = 'john';
document.write(name);

```

it will write the **variable** you have declared upper