EN
jQuery - how to add on click event to button?
0 answers
14 points
I have simple html button and I would like to add on click event to this button.
When someone clicks on this button I would like to show alert.
I don't want to use plain JavaScript, I would like to achieve it with jQuery.
My button looks like this:
xxxxxxxxxx
1
2
<html>
3
<head>
4
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
5
</head>
6
<body>
7
<script>
8
// code to add on click to button
9
</script>
10
<button id="button-id">My button</button>
11
</body>
12
</html>
I would like to get element by id and attach click event with jQuery.
0 answers