Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So..
My issue im having is that I cant declare any JQuery functions because my JQuery file doesnt want to work or so it seems..

This is around the 3rd time its struggleing with me.
I've tried changing it to the file directory but It doesnt want to join my side & co-op..

This is what the issue looks like, as you can see the text is white as in it doesnt function properly;

http://imgur.com/jHzExKb[^]

This is how my files are setup;

https://gyazo.com/d10124468e6bfdf8b47ece2f9f1cb5cb[^]

https://gyazo.com/9d356f815ed5c1b4594e3129e8eacd6d[^]

& here is what the source code looks like


HTML
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Full Width Responsive Image Slider</title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script src="http://malsup.github.com/jquery.cycle2.js"></script>
  <style type="text/css">
  html,body,img {padding: 0; margin: 0;height:100%;width:100%}
  body {font-family: "Helvetica Neue", Helvetica, Arial;}



$(document).ready(function(){

		$('#sidebar-btn').click(function(){
				$('#sidebar').addClass('visible');



			});

	});

  .container{

  	height:100%;
  	width:100%;
  	overflow: hidden;

  }

  .cycle-slideshow {
  	  height: 100%;
      width: 100%;
      display: block;
      position: relative;
      margin: 0 auto;

  }
  .cycle-prev, .cycle-next {
      font-size: 200;
      color: #FFF;
      display: block;
      position: absolute;
      top: 50%;
      margin-top: -16px;
      z-index: 9999;
      cursor: pointer;

  }

  .cycle-prev {left: 10%;}
  .cycle-next{right: 10%;}


  .cycle-pager{
      width: 100%;
      text-align: center;
      display: block;
      position: absolute;
      position: top;
      bottom: 20px;
      z-index: 9999;
  }

  .cycle-pager span {
      text-indent: 100%;
      white-space: nowrap;;
      width: 12px;
      height: 12px;
      display: inline-block;
      border: 1px solid #FFF;
      border-radius: 50%;
      margin: 0 10px;
      cursor: pointer;

  }
  .cycle-pager .cycle-pager-active {background: #FFF;}


  #sidebar{

	
		background: #151718;
		width:200px;
		height:100%;
		display:block;
		position:absolute;
		left:-200px;
		top:0px;
		transition: left 0.3s linear;

}

#sidebar.visible{
	left: 0px;
	transition: left 0.3s linear;
}

ul {

	margin: 0;
	padding: 0;

}

ul li{
	list-style: none;


}


ul li a{

	background: #1C1E1F;
	color: #ccc;
	border-bottom: 1px solid #111;	
	display: block;
	width:  180px;
	padding: 10px;
	text-decoration: none;


}


#sidebar-btn{
display: inline-block;
vertical-align: middle;
width: 20px;
height: 150px;
cursor: pointer;
margin-bottom: 20px;


	
}

#sidebar-btn span{
height: 1px;
background: #111;
margin-bottom: 5px;
display: block;

	
}


#sidebar-btn span:nth-child(2){
width: 75%;

	
}


#sidebar-btn span:nth-child(3){
width: 50%;

	
}

/*Menu CSS*/


/*Menu CSS*/

  </style>
</head>
<body>




<div id="sidebar">


	<ul>
		<li><a href="#">Link1</a></li>
		<li><a href="#">Link2</a></li>
		<li><a href="#">Link3</a></li>
		<li><a href="#">Link4</a></li>
	</ul>


</div>


<div id="sidebar-btn">
	<span></span>
	<span></span>
	<span></span>
</div>




<!-- Full Width Responsive Slider -->

 <div class="container">

<!--      <div class="cycle-slideshow">
    <span class="cycle-prev">&#9001;</span>
    <span class="cycle-next">&#9002;</span>
    <span class="cycle-pager"></span>
    <img src="images/picOne.jpg">
    <img src="images/picTwo.jpg">
    <img src="images/picThree.jpg">
  </div> -->
<!-- Full Width Responsive Slider -->


</body>

</html>
Posted
Updated 18-Dec-15 0:35am
v2

1 solution

You need to put your js inside a script tag, you were also missing an end div tag

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Full Width Responsive Image Slider</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="http://malsup.github.com/jquery.cycle2.js"></script>
    <style type="text/css">
            html, body, img {
                padding: 0;
                margin: 0;
                height: 100%;
                width: 100%;
            }

            body {
                font-family: "Helvetica Neue", Helvetica, Arial;
            }

        .container {
                height: 100%;
                width: 100%;
                overflow: hidden;
            }

            .cycle-slideshow {
                height: 100%;
                width: 100%;
                display: block;
                position: relative;
                margin: 0 auto;
            }

            .cycle-prev, .cycle-next {
                font-size: 200;
                color: #FFF;
                display: block;
                position: absolute;
                top: 50%;
                margin-top: -16px;
                z-index: 9999;
                cursor: pointer;
            }

            .cycle-prev {
                left: 10%;
            }

            .cycle-next {
                right: 10%;
            }


            .cycle-pager {
                width: 100%;
                text-align: center;
                display: block;
                position: absolute;
                position: top;
                bottom: 20px;
                z-index: 9999;
            }

                .cycle-pager span {
                    text-indent: 100%;
                    white-space: nowrap;
                    ;
                    width: 12px;
                    height: 12px;
                    display: inline-block;
                    border: 1px solid #FFF;
                    border-radius: 50%;
                    margin: 0 10px;
                    cursor: pointer;
                }

                .cycle-pager .cycle-pager-active {
                    background: #FFF;
                }


            #sidebar {
                background: #151718;
                width: 200px;
                height: 100%;
                display: block;
                position: absolute;
                left: -200px;
                top: 0px;
                transition: left 0.3s linear;
            }

                #sidebar.visible {
                    left: 0px;
                    transition: left 0.3s linear;
                }

            ul {
                margin: 0;
                padding: 0;
            }

                ul li {
                    list-style: none;
                }


                    ul li a {
                        background: #1C1E1F;
                        color: #ccc;
                        border-bottom: 1px solid #111;
                        display: block;
                        width: 180px;
                        padding: 10px;
                        text-decoration: none;
                    }


            #sidebar-btn {
                display: inline-block;
                vertical-align: middle;
                width: 20px;
                height: 150px;
                cursor: pointer;
                margin-bottom: 20px;
            }

                #sidebar-btn span {
                    height: 1px;
                    background: #111;
                    margin-bottom: 5px;
                    display: block;
                }


                    #sidebar-btn span:nth-child(2) {
                        width: 75%;
                    }


                    #sidebar-btn span:nth-child(3) {
                        width: 50%;
                    }

            /*Menu CSS*/


            /*Menu CSS*/
    </style>
</head>
<body>




    <div id="sidebar">


        <ul>
            <li><a href="#">Link1</a></li>
            <li><a href="#">Link2</a></li>
            <li><a href="#">Link3</a></li>
            <li><a href="#">Link4</a></li>
        </ul>


    </div>


    <div id="sidebar-btn">
        <span></span>
        <span></span>
        <span></span>
    </div>




    <!-- Full Width Responsive Slider -->

    <div class="container">

        <!--      <div class="cycle-slideshow">
            <span class="cycle-prev">〈</span>
            <span class="cycle-next">〉</span>
            <span class="cycle-pager"></span>
            <img src="images/picOne.jpg">
            <img src="images/picTwo.jpg">
            <img src="images/picThree.jpg">
          </div> -->
        <!-- Full Width Responsive Slider -->

        </div>
    <script type="text/javascript">
    $(document).ready(function(){

        $('#sidebar-btn').click(function(){
            $('#sidebar').addClass('visible');

        });
    }); 
    </script>
</body>

</html>
 
Share this answer
 
Comments
BladeLogan 18-Dec-15 6:53am    
Oh my.. Im kinda new to JQuery Ive been working on this project for the past 9-10 or so hours.. getting tunnel vision. Thanks alot sir!
BladeLogan 18-Dec-15 7:00am    
Oh one more thing.. This is probably a really dumb question but I feel like it needs to be asked, How come I cant have that code snipped the
-----------------------------------------------------
<script type="text/javascript">
$(document).ready(function(){

$('#sidebar-btn').click(function(){
$('#sidebar').addClass('visible');

});
});
</script>
-----------------------------------------------------
on the top of my code, it only works when its inside of the bod... ooh.. well I think I just answered my own question.
F-ES Sitecore 18-Dec-15 7:23am    
You can put it in the head if you want, but it can't be nested inside another tag such as the style tag, and it has to appear after the link to jquery
BladeLogan 18-Dec-15 7:25am    
Oh! I'l use this answer as a reminder so I can remember that next time! Thank you for explaining!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900