Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>Document</title>
  9. <link rel="stylesheet" href="style.css">
  10. </head>
  11.  
  12.  
  13. <script>
  14. function myFunction() {
  15. var letters = document.getElementById('text');
  16. for (var i = 0; i < letters.innerHTML.length; i++) {
  17. //only change the one you want to
  18. if (i == 4) {
  19. letters.innerHTML = letters.innerHTML.replace(letters[i], '<span style="color: yellow;">'+letters[i]+'</span>');
  20. }
  21. }
  22. }
  23. </script>
  24.  
  25. <div id="text">
  26. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fuga, dolores nostrum! Repellendus recusandae eum maiores incidunt
  27. cum temporibus, exercitationem sequi fugiat, at accusantium, voluptas fuga.
  28. </div>
  29.  
  30. <script>
  31. myFunction();
  32. </script>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement