$(document).ready(function(){
var nam="";
$("#sayHello").click(function(){
nam = $("#textBox1").val();
if(nam == ""){
alert("Please let know what your name is.");
}
else if(/ /i.test(nam)){
alert("Try to make sure that your not adding an extra space. It can be any name make one up if that helps.");
}
else{
$("#welcome").html("<p id='hi'>Hello "+ nam +",</br> How was your day?</br>" +
"<button id='good'>GOOD</button> <button id='okay'>okay</button>" +
" <button id='bad'>Bad</button></p>").show();
$("#inputBox").hide();
}
});
$("#good").click(function(){
$("#goodHit").html("<h3>I'm so happy for you!</h3>" +
"<p>Here is a quote to help you along your way.</p>" +
"<blochquote>The good old days are now.</blochquote>" +
"<figcaption>Tom Clancy</figcaption>").show();
$("#hi").hide();
});
});
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<div id="container">
<div id="inputBox">
Here is my first text box.
<input id="textBox1" type="text" value=""/>
<button id="sayHello">Submit</button>
</div>
<div id="welcome">
</div>
<div id="goodHit">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="myJQ.js"></script>
</body>
</html>
In my first .click(function(){..}); I make some buttons and put them into a div. I then hide my div that gave me that ability and show the buttons but when I want to use those buttons nothing is happening. I am new to javascript and jquery please help. here is my code.
$(document).ready(function(){
var nam="";
$("#sayHello").click(function(){
nam = $("#textBox1").val();
//some checks are here but unimportant
Here is where the buttons are made and put into my html.
$("#welcome").html("<p id='hi'>Hello "+ nam +",</br> How was your day?</br>" +
"<button id='good'>GOOD</button> <button id='okay'>okay</button>" +
" <button id='bad'>Bad</button></p>").show();
$("#inputBox").hide();
}
});
I then try and use one for what I want next to happen.
$("#good").click(function(){
$("#goodHit").html("<h3>I'm so happy for you!</h3>" +
"<p>Here is a quote to help you along your way.</p>" +
"<blochquote>The good old days are now.</blochquote>" +
"<figcaption>Tom Clancy</figcaption>").show();
$("#hi").hide();
});