Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <script type="text/javascript">
  2. window.addEvent('domready', function() {
  3. var count = 0;
  4. $('p#add_field').click(function(){
  5. count += 1;
  6. $('#container').append(
  7. '<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" /><br />' );
  8. });
  9. });
  10. </script>
  11.  
  12. <div id="container">
  13. <p id="add_field"><a href="#"><span>&raquo; Add your favourite links.....</span></a></p>
  14. </div>
  15.  
  16. jQuery(document).ready(function() {
  17. //do stuff
  18. })
  19.  
  20. <script type="text/javascript">
  21. $(function() {//shorthand way of doing document.ready
  22. var count = 0;
  23. $('p#add_field').click(function(){
  24. count += 1;
  25. $('#container').append(
  26. '<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" /><br />' );
  27. });
  28. });
  29. </script>
  30.  
  31. $document =& JFactory::getDocument();
  32. $document->addScript("jquery-1.8.1.min.js");
  33. $js = " $(document).ready(function() {
  34. var count = 0;
  35. $('p#add_field').click(function(){
  36. count += 1;
  37. $('#container').append('<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" /><br />' );
  38. });
  39. });";
  40. $document->addScriptDeclaration($js);
  41.  
  42. <head>
  43. <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  44. <script>
  45. var count = 0;
  46. $(document).ready(function() {
  47. $('p#add_field').click(function(){
  48. count += 1;
  49. $('#container').append('<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" /><br />' );
  50. });
  51. });
  52. </script>
  53. </head>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement