Goal:
Show the button "Candy Candy candy" after pressing the button text "Test2"
Problem:
It doesn't show the text and what part am I missing in order to complete it?
I have tried using on() and live() but it still doesn't work.
Info:
*I'm using jQuery and its ajax
Thank you!
$('#test1').click(function() {
document.getElementById("data1").innerHTML = "<button id='test2' type='button'>Test 2</button>";
});
$('#test2').click(function() {
document.getElementById("data2").innerHTML = "Candy candy candy !";
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<button id="test1" type="button">Test 1</button>
<br/>
<br/>
<div id="data1"></div>
<br/>
<br/>
<div id="data2"></div>
</body>
</html>