jQuery troubleshooting techniques -


i'm trying find problem in code below q&a toggle panel each h3 question followed div answer. particular code supposed go through questions , answers , close open.

i'm not asking here what's wrong code if there might tricks troubleshooting don't know about. example, when .next() shifts on div h3, nice have variable somewhere represented div jquery object, i.e, result of next(). , in slidetoggle(1000) nice see the toggle state variable slidetoggle() looking at.

$('#qa h3').each(function() { debugger; this$ = $(this); if(this$.hasclass('ui-state-active')) {     this$.toggleclass("ui-state-active ui-state-default")    .next()     .toggleclass("ui-accordion-content-active")     .slidetoggle(1000); }  

thanks suggestions

you can print variables you're requesting console using console.log.

$('#qa h3').each(function() {   debugger;    $this = $(this);   console.log($this);    if($this.hasclass('ui-state-active')) {     console.log('$this has class .ui-state-active');     console.log('$this.next() = ' + $this.next());      $this.toggleclass("ui-state-active ui-state-default").next().toggleclass("ui-accordion-content-active").slidetoggle(1000);   } } 

just books, think issue you're missing curly brace. i've added missing brace above code.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -