1

I want to click in the div or the img and get the text of the p inside it to go in another list.

 <div onClick="add_basket(this);" class="menu-item burger"> <img  src="img\McDo\bigmac.png"> <p>Big Mac</p> </div>
  <div onClick="add_basket(this);" class="menu-item burger"> <img  src="img\McDo\doubleqp.png"> <p>Double Quarter Pounder</p> </div>


   <ul class="basket" id="basket-mcdo">
    <li>Order</li>
    <li>Mcdo</li>
  </ul>

and i have a lot of others like that and here is my function but it doesn't work it adds "undefined" is the list

function add_basket(that) {
    $(".basket").append("<li>"+that+"</li>");
}

Thank you very much for your help :)

m4n0
  • 29,823
  • 27
  • 76
  • 89
  • use `var text = $(that).child('p').innerHTML;` inside the `add_basket` function before appending the text - `$(".basket").append("
  • "+text+"
  • ");` Not much familiar with jquery – Rohit Kumar Aug 28 '15 at 20:02
  • @RohitKumar That will not work. – Ram Aug 28 '15 at 20:07
  • where is the error? should use `children` instead of `child`? OHH I got it, I need to use `.html()` instead of `innerHTML`, right?? – Rohit Kumar Aug 28 '15 at 20:08
  • Right. After implementing those changes it will work. – Ram Aug 28 '15 at 20:10