Problem 01:
I have just begun my Jquery/Javascript journey and am having issues moving the output from the script to the top of the page above the link so the toggle does not affect it. If I move the script to the top then it runs before the HTML gets loaded.
Problem 02:
Could I also get some tips as to how I can apply CSS to those variables?
Ex: put into a box and change fonts/color etc
<html>
<head>
<title>Films</title>
<link rel="stylesheet" href="css/layout.css" type="text/css">
</head>
<body>
<h1 class="mainheading">Films</h1>
<a href="#" id="actionlink">Add a Film</a>
<div id="jquerytarget">
<form>
<p><label>Film</label><br />
<input type="text" name="film" id="film"></p>
<p><label>Rating</label><br />
<select name="rating" id="rating">
<option value="1">One Star</option>
<option value="2">Two Stars</option>
<option value="3">Three Stars</option>
</select>
</p>
<p><label>Description</label><br />
<textarea name="filmdescription" id="filmdescription"></textarea></p>
<p><button id="submit">Submit</button></p>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#actionlink").click(function() {
$("#jquerytarget").slideToggle(200);
});
});
</script>
<script id="output" type="text/javascript">
$("#submit").click(function(e) {
e.preventDefault();
var film = $("#film").val();
$("#jquerytarget").prepend("<p>" + film + "</p>")
var rating = $("#rating").val();
$("#jquerytarget").prepend("<p>" + rating + "</p>")
var filmdescription = $("#filmdescription").val();
$("#jquerytarget").prepend("<p>" + filmdescription + "</p>")
});
</script>
</body>
</html>