Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to call a href by onclick event of a button?
  2. <a class='openDialog' data-dialog-id='myEditDlg' data-dialog-autosize='false' data-dialog-alt='580' data-dialog-larg='740' data-dialog-title='test dialog' href='/mycontroller/EditDlg/myid'></a>
  3.        
  4. $('#link').click();//No arguments inside the call.
  5.        
  6. location.href=$('#link').attr('href');
  7.        
  8. $('#button').click(function(){$('#link').click();
  9.    location.href=$('#link').attr('href');//In case the page doesn't change although you want it to
  10. }
  11.        
  12. <button id="bt">Click</button>
  13. <a href="example.com" id="ex">Triggerable link</a>
  14.  
  15. <script type="text/javascript">
  16.   $('#bt').click(function() {
  17.        $('#ex').click();
  18.   });
  19. </script>