how to click an anchor tag from javascript or jquery -


this sample code, trying click javascript not responding.. while load page should go next.php without click anchor tag. pls me, how this?

<!doctype html>     <html>     <head>         <title></title>         <script src="jquery-2.0.3.js"></script>         <script type="text/javascript">            alert("hai");            $(document).ready(function() { $('#about').click(); });                      </script>     </head>      <body>             <div>                 <a href="next.php" id="about">click here</a>             </div>     </body>     </html> 

use $('selector')[0], $('selector') returns jquery object, $('selector').click() fire click handler, while $('selector')[0].click() fire actual click.

$(document).ready(function () {     $('#about')[0].click();  //$('#about').get(0).click(); }); 

demo


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -