Land Seagull Land Seagull - 4 months ago 28
jQuery Question

jQuery in Brackets Live Preview not working

I have the beginning of I note taking website I am making as an experiment. It was working fine in the live preview from brackets, but then I saved the files and now none of the jQuery works. I think it is my code by it could also be something with Brackets since it only happened once I saved. Here is my code:



$(document).ready(function() {

var notes = [];

$("#newNoteWrapper").hide();

$(".text").focus(function() {

$(this).stop
$(this).animate({
marginLeft: "+=3%"
});

});
$(".text").blur(function() {

$(this).stop
$(this).animate({
marginLeft: "-=3%"
});

});

$(".button").hover(function() {

$(this).stop();
$(this).animate({
backgroundColor: "#108cb1"
}, 200);

}, function() {

$(this).stop()
$(this).animate({
backgroundColor: "#2DBEEB"
}, 200);

});

$("#newNoteButton").click(function() {

newNote(true);

});


$("#doneButton").click(function() {

newNote(false);

});
});

var newNote = function(enter) {

if enter {
$("#newNoteWrapper").show();
} else {
$("#newNoteWrapper").hide();
notes.push({
title: $("#noteTitle").val(),
body: $("#noteBody").val(),
});
}
}

html,
body {
padding: 0;
margin: 0;
border: 0;
background-color: #FFFFFF;
font-family: sans-serif;
}
.button {
padding: 15px 25px;
border: none;
font-size: 25px;
margin-bottom: 10px;
background-color: #2DBEEB;
color: #FFFFFF;
outline: none;
}
.text {
border: none;
outline: none;
width: 92%;
border-left: 10px solid #2DBEEB;
resize: vertical;
background-color: #FFFFFF;
}
#newNoteButton {
margin: 10px;
}
#newNoteWrapper {
z-index: 2;
position: absolute;
height: 100%;
width: 100%;
background-color: #FFFFFF;
top: 0%;
}
#newNote {
background-color: #2DBEEB;
color: #FFFFFF;
font-size: 30px;
padding: 10px;
text-align: center;
}
#noteTitle {
font-size: 25px;
height: 50px;
margin: 10px 0px 10px 0px;
}
#noteBody {
font-size: 12pt;
height: 500px;
margin: 0px 0px 10px 0px;
}
#doneButton {
left: 0;
position: absolute;
margin-left: 10px;
}

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" type="text/css" href="notes.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.color-animation/1/mainfile"></script>
<script src="notes.js"></script>
<title>Simple Notes</title>
</head>

<body>

<button id="newNoteButton" class="button">new note</button>
<div id="newNoteWrapper">
<div id="newNote">new note</div>
<form>
<input type="text" id="noteTitle" class="text" placeholder="title..."></input>
<textarea id="noteBody" class="text" placeholder="body..."></textarea>
<br />
<button id="doneButton" class="button">done</button>
</form>

</div>

</body>

</html>





Is there something wrong with this or should I try a different editor?

Answer

you must edit the follwing of

In HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.color-animation/1/mainfile"></script>

In JS

var newNote = function(enter) {

   if (enter) {
      $("#newNoteWrapper").show();
   } else {
      $("#newNoteWrapper").hide();
      notes.push({
         title: $("#noteTitle").val(),
         body: $("#noteBody").val(),
      });
   }
}