0
<a href="javascript:__doPostBack('btnContinuePhone','')" class="button-hpo blue-button-23" id="btnContinuePhone" onclick="javascript:return ConfirmModalPopUp('phone');"><span>Next</span></a>

I want to change the href of this button and also removing on click. Could anybody tells me how to do it in jquery?

Clive
  • 36,705
  • 8
  • 79
  • 108
Noname
  • 61
  • 1
  • 2
  • 8
  • Next..this is code for button.. – Noname Oct 18 '11 at 16:57
  • Related post here: http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery – Dan Oct 18 '11 at 16:57
  • This suspiciously looks like ASP.NET code. Why not just remove it in your c#/vb code in the first place? Also, `onclick="javascript:…"` is wrong, onclick can only take javascript code, so it's unnecessary to add the javascript pseudo protocol – knittl Oct 18 '11 at 16:59
  • Thank you!I should need to do in javascript or jquery.. – Noname Oct 18 '11 at 17:10

3 Answers3

2

You can try something like this:

var el = $("#element");
if (el){
    el.unbind("click");
    el.attr("href", "newpage.htm");
}
James Johnson
  • 43,670
  • 6
  • 67
  • 106
1

Here is a demo attached: http://jsfiddle.net/xavi3r/DQ4Sn/

$('#btnContinuePhone').click(function(){
   return false; 
});
$('#btnContinuePhone').attr('href','http://newurl.com');
Xavier
  • 7,758
  • 17
  • 51
  • 84
  • 1
    Won't that simply add a second click event, rather than unbinding an existing one? See here for reference: http://stackoverflow.com/questions/209029/best-way-to-remove-an-event-handler-in-jquery – Colin Brock Oct 18 '11 at 17:00
  • Actually one popup will come when i click on next button. I don't want that popup to come, I want to go to next page without coming popup. Thought of changing href,or deleting the onclick. Both did not work. Any help i appreciated.Thanks! – Noname Oct 18 '11 at 20:18
0

This is my solution :

$('#btnContinuePhone').attr('href', 'what ever you like');
$('#btnContinuePhone').click(function(){ return false;});

Or you can do that alternativly:

$('#btnContinuePhone').attr('href', 'what ever you like');
$('#btnContinuePhone').click(function(e){ e.preventDefault(); });
KodeFor.Me
  • 11,719
  • 19
  • 82
  • 154
  • this has href:"javascript:__doPostBack('btnContinuePhone','')"..will it work?? – Noname Oct 18 '11 at 17:33
  • Actually one popup will come when i click on next button. I don't want that popup to come, I want to go to next page without coming popup. Thought of changing href,or deleting the onclick. Both did not work. Any help i appreciated.Thanks! – Noname Oct 18 '11 at 20:18