I've been a little confused as how I'm supposed to connect my jquery to my page, and I'm still still relatively new to learning javascript/jquery. When I put the script in the head nothing happens when I click on the I have set up in my file below. But on my jfiddle it works fine.
I have a portion of my site where I want to have a mock iphone where people who visit the page can click on it.
I used this jfiddle I found on stack overflow: how to make div slide from right to left
There's a link that goes to jqueryui and shows the script for the slide effect there. Am I supposed to use this in the head?
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
This is my jfiddle that I tweaked slightly as to what I'm looking to achieve: http://jsfiddle.net/tokyothekid/weujtht5/
Here's my current code in the head:
<link rel="stylesheet"href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$( document ).click(function() {
$('#iphone-button1').click(function(){
if ($('#iphone-panel2').is(':hidden')) {
$('#iphone-panel2').show('slide',{direction:'right'},1000);
} else {
$('#iphone-panel2').hide('slide',{direction:'right'},1000);
}
});
</script>
Here is my html:
<div id="iphone-panel1">
logo
<a id="iphone-button1">start</a>
</div>
<div id="iphone-panel2">User Area</div>
My CSS:
#iphone-panel1{
width:200px;
height:200px;
position:absolute;
}
a {
color: #000;
cursor:pointer;
display:block;
}
#iphone-panel2 {
width: 200px;
height: 200px;
display: none;
background: red;
position:relative;
}
Appreciate all the help