Check out my code snippet below:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="js/jquery-1.7.2.min.js"></script>
<style>
div {
border: 2px solid black;
width: 200px;
min-height: 300px;
}
</style>
</head>
<body>
<div>
<p id="demo">This will change</p>
<input type="button" value="OK" onclick="myFunction()"/>
</div>
<script>
$(document).ready(function()
{
$("input").click(function()
{
if($("div").height() === 300){
document.getElementById("demo").innerHTML = "HELLO WORLD!";
}
});
});
</script>
</body>
</html>
I am trying to achieve the functionality where clicking a button will change the text in the paragraph within a div element, based on its height. This is my first attempt at using JavaScript for this purpose. Any help or suggestions are appreciated.