I am trying to change the CSS of a webpage based on form inputs using jQuery and regular JS. I am having a very difficult time with this and can't find the right solution. I was trying out the JavaScript and jQuery with the red radio button, but included all HTML for good measure. I have spent hours rewriting the code and am stuck. Please help.
HTML
<!--Form that user fills out to change css styling of the page-->
<form id="cssStyling">
<label for="fontChange">Choose a font:</label>
<select id="fontChange" name="fontChange">
<option value="Times">Times</option>
<option value="Georgia">Georgia</option>
<option value="Helvetica">Helvetica</option>
<option value="Verdana">Verdana</option>
</select>
<br><br>
<p>What color should the paragraph font be?</p>
<!--red radio button-->
<input type="radio" id="red" name="colorP" value='red' required>
<label for="red" > Red</label>
<!--blue radio button-->
<input type="radio" id="blue" name="colorP" value="blue">
<label for="blue" > Blue</label>
<!--green radio button-->
<input type="radio" id="green" name="colorP" value="green">
<label for="green"> Green</label>
<br><br>
<p>Which page elements should have borders?</p>
<!--Checkbox and label for h1-->
<input type="checkbox" id="heading1" name="elements">
<label for="heading1">h1 element</label>
<!--Checkbox and label for h2-->
<input type="checkbox" id="heading2" name="elements" value="heading2">
<label for="heading2">h2 element</label>
<!--Checkbox and label for p-->
<input type="checkbox" id="paragraphs" name="elements">
<label for="paragraphs">p element</label>
<br><br>
<input type="submit" value="Click to submit styling changes" />
</form>
<!--End form-->
<h1>I am h1</h1>
<p>I am p</p>
<h2>I am h2</h2>
JavaScript
$(function() {
$('#cssStyling').on('submit', function(evnt) {
evnt.preventDefault();
var n = $("select").val();
// If the value is less than 7, add a red border
if (n == "red") {
$("p").css("color", "red");
}
});
});