$(this) context

$(this) context

What I'm trying to do is changing the text of a div when pressing a button. Since the button is inside a div that's inside the div I'm trying to change the text of, I did this:

  1. function changeQuan() {
  2.       $(this).parent().parent().text("lel");
  3.       alert($(this).parent().parent().text());
  4. }

The alertbox itself shows up, but there's nothing inside. When alerting without .text() it returns an object, so I guess this should work, but it doesn't.

The divs and buttons are inserted with php:

  1. $output .= "<div class='imageWrapper'>
  2.                         <div class='quantitySquare'>
  3.                               <div class='manipQuan'>
  4.                                     <button class='incButton' onclick='changeQuan()'>+</button><button class='decButton' onclick='changeQuan()'>-</button></div>"
  5.                         .$row["quantity"]."x</div>
  6.                         <img class='imgTag' src='images/".$card->id.".jpeg' /></div>";

Maybe it has something to do with that?