Advertisement
firoze

Replace text by jQuery

Feb 15th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. // Replace text by javascript
  2. <script type="text/javascript">
  3. jQuery(document).ready(function(){
  4. jQuery('small#copyright').empty('© 2014 Styled Wheels. All Rights Reserved');
  5. jQuery('small#copyright').append('© 2014-<?php echo date('Y');?> Styled Wheels. All Rights Reserved');
  6. });
  7. </script>
  8. <small id="copyright">© 2014 Styled Wheels. All Rights Reserved</small>
  9.  
  10.  
  11.  
  12. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13.  
  14. Another method
  15. <!DOCTYPE html>
  16. <html lang="en">
  17. <head>
  18. <meta charset="utf-8">
  19. <title>Hello User!</title>
  20. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  21. <script type="text/javascript">
  22. $(document).ready(function() {
  23. $(".element span").text(function(index, text) {
  24. return text.replace('British Pound', 'GBP'); // here "British Pound" will be changed by "GBP"
  25. });
  26. });
  27. </script>
  28. </head>
  29. <body>
  30. <div class="element">
  31. <span>1 British Pound</span>
  32. </div>
  33. </body>
  34. </html>
  35.  
  36. ///////////////////////////////////////////////////////////////////////////////////////////
  37.  
  38. another method
  39.  
  40. <div class="slider-article">
  41. <h2>This is slider title</h2>
  42. </div>
  43.  
  44.  
  45. <script type="text/javascript">
  46. jQuery(document).ready(function(){
  47. jQuery('.slider-article h2').empty('This is slider title').append('<i>hello world!</i>');
  48. });
  49. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement