0

Description : Hello I am developing Online food ordering site. I have almost completed the project but i am stuck at shopping cart..

Problem: I am facing problem when i delete the item from the cart which i have selected the page is scrolling up when i delete item from the cart.. I am using AJAX to add and delete items from the cart.

What will be the possible solution so that page do not scroll up when i delete the item from cart.??

You can check out here is the link : http://gogaily.com/restaurant_details.php?hotel_id=14 after page redirects click on MENU tab to view Menu items ... When u click on Menu items Cart will be displayed ,once u delete the item from cart Page scroll up.. How to avoid the page getting scrolled up.

krish
  • 641
  • 3
  • 9
  • 26

3 Answers3

1

I think you have used anchor tag in delete button. ie.

<a href="#" ...>Delete</a> 

something like this. Do it with

<a href="">Delete</a> 

or use button i.e.

<button ...>Delete</button>

Hope you problem will be solved.

Tahmina Khatoon
  • 1,081
  • 3
  • 11
  • 29
1

That’s because you are using a link element with href="#" – the empty hash gets treated as “scroll to top” by browsers.

You simple have to suppress the “normal” link functionality after executing your JS code – keywords are event.preventDefault or return false (the latter for “traditional” event handling.

CBroe
  • 91,630
  • 14
  • 92
  • 150
0

Replace href="#" with href="javascript:void();"

karmafunk
  • 1,453
  • 12
  • 20
  • See this post http://stackoverflow.com/questions/134845/href-attribute-for-javascript-links-or-javascriptvoid0 – karmafunk Mar 15 '13 at 16:18