Embedding URL in html using jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

Embedding URL in html using jQuery

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-2.1.0.js"></script> 
   </head> 
   <body> 
      <div class="class"></div> 
      <script type="text/javascript">
var link = "http://example.org"
$('.class').append('<a href="#" onclick="myFunction(\'' + link + '\')">Foo</a>');
function myFunction(url) {/*from  www .java 2  s.  co  m*/
    console.log(url);
}

      </script>  
   </body>
</html>

Related Tutorials