NTS Forums

Please login or register.

Login with username, password and session length
 

News:

Welcome to the Newtek Technology Services Forum!


Author Topic: Jquery - Feeling Dumb at the Moment.  (Read 2980 times)

Offline gpalz

  • Hosting Newbie
  • *
  • Posts: 16
  • Karma: +2/-0
Jquery - Feeling Dumb at the Moment.
« on: July 09, 2014, 06:50:14 PM »
Good evening forum members,

I'm trying to create a simple text toggle in jquery, but nothing happens. Can't see what I'm doing wrong. Below is the jquery and html code. Appreciate any insights. Feeling dumb at the moment.   Thank you for your time and words.

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>
$('.toggleDiv').click(function(){
this.next().toggle();
});
</script>


<a href="#" class="toggleDiv">Click here to toggle div.</a>
<div>This is the toggle div</div>

Offline gpalz

  • Hosting Newbie
  • *
  • Posts: 16
  • Karma: +2/-0
Re: Jquery - Feeling Dumb at the Moment.
« Reply #1 on: July 09, 2014, 07:16:05 PM »
Just realized I didn't wrap it within a function:

    $(function(){
        $('.toggleDiv').click(function(){
        $(this).next('div').toggle();
        });
    });