I am trying to make a button open up another window using jquery.
The button should be able to open the window. Then the same button should be used to close the window afterwards. The problem I seem to be having appears that my variables are not being set after the button opens the window. I am really new to javascript and jquery, so I'm not sure if I did something wrong.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var FileEdit = 0;
$(document).ready(function(){
if (FileEdit == 0)
{
$("button").click(function(){
$("div").animate({opacity:0.4},"fast");
$("div").animate({height:300,width:300},"slow");
$("div").animate({opacity:1},"slow");
FileEdit = 1;
});
}
if (FileEdit == 1)
{
$("button").click(function(){
$("div").animate({height:000,width:000},"slow");
FileEdit = 0;
});
}
});
</script>
</head>
<body>
<button>Start Animation</button>
<br /><br />
<div style="background:#98bf21;height:000px;width:000px;">
</div>
</body>
</html>
$("div")in a variable.$("div")on every line, jQuery will search for all div elements three times. By usingvar divs = $("div");you can use that variable on the other lines, and just have one lookup, or use chaining like$("div").doSomthing().doSomethingElse();