Create an anchor link - Javascript jQuery

Javascript examples for jQuery:Link

Description

Create an anchor link

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.4.js"></script> 
  <script type="text/javascript">
    $(function(){/*w  ww.ja  v  a 2 s  .  com*/
$('#myDiv').append(
    $('<a>').append("click").attr('href', 'A sensible fallback').click(function (e) {
        console.log('TERM');
        e.preventDefault();
   })
);
    });

      </script> 
 </head> 
 <body> 
  <div id="myDiv"></div>  
 </body>
</html>

Related Tutorials