Jump to content

JavaScript+JQuery!? How to disable automatic reload function for my button!?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
when I use this code:
$('#prim').click(function(){


   if (sr==17) 

   { 

    $('#prim').attr("value","try again");

  	$('#prim').click(window.location.reload());

	};

 )};
it's always automaticly reloading my page, but I want that it's work when I clicked this button?

#2
Mark Wylde

Mark Wylde

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
Try the following adjustment. By adding return false to the onClick event it should tell the browser to stop any browser related tasks after running your script.


$('#prim').click(function(){


   if (sr==17) 

   { 

    $('#prim').attr("value","try again");

  	$('#prim').click(window.location.reload());

	};

     return false;

 )};






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users