Question: I want to Pass the variable with click event in jquery

```
var get=3; 
$('#edit').click(function(event){
alert('You are getting:' + get);
}

```

please help me

html 

```
<input type='submit' name='action' id='edit' />

```

Answer: 
HTML button

```
<button id='my_button' type='button' data-id='1' data-values='1' value='6' data-whatever='20'>My button</button>

```

Jquery

```
$('#my_button').bind('click', function() {
    var value = $(this)val();
    var whatever = $(this).data('whatever');
    var id = $(this).data('id');
    var values = $(this).data('values');
    console.log(value);
    console.log(whatever);
    console.log(id);
    console.log(values);

});

```

1. Open Firefox > Inspect Element > Console Tab.
2. Load the codes
3. Click the button
4. See response
Can you try like this, 

```
<script type="text/javascript">
  function test(ev) {
    var id = $(ev).attr('id');
    alert(id);
  }
</script>

<input id="btn" type="button" value="click" OnClick="test(this);" />

```