it's your use of next() that's incorrect. You have 2 cases of HTML now so explanation a little trickier. Original html .arrow was a descendant not a sibling, next() looks for siblings so in 1st case changing to find() or children() would work

Second case HTML, next looks down the DOM and arrow was up the DOM. siblings() or prev() in place of next() should work

captaincarp wrote:
Have you tried .addClass() and .removeClass() and setting up a different
action for each, thus simulating toggle?




craigeves wrote:
  
Hi

Can anyone help? I'm trying to toggle a class on the span .arrow when
you click .msg_head. I have several classes of .arrow on the page and
only want to toggle the class of the span within the element i'm
clicking. This is my code - but it doesn't work... any advice?

Thanks

Craig


$(".msg_head").click(function(){
		$(this).next(".msg_body").slideToggle("slow");
		$(this).next(".arrow").toggleClass("arrow_up");
	});



 <div class="msg_list">
            <div class="panel">
              <div class="msg_head">Design supplied by us</div>
              <div class="msg_body m10">
                <p>orem ipsum dolor sit amet, consectetuer adipiscing
elit orem ipsum dolor sit amet, consectetuer adipiscing elit </p>
                <p class="last"> designsupplied.php Design by
you </p>
              </div>
            </div>
            <div class="msg_head">Design supplied by you</div>
            <div class="msg_body">
              <p>orem ipsum dolor sit amet, consectetuer adipiscing
elit orem ipsum dolor sit amet, consectetuer adipiscing elit </p>
              <p class="last"> design.php Design by you </
p>
            </div>
          </div>


    

  

Reply via email to