Advertisement
cherryprodesign

Title formázás

Jul 1st, 2016
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CSS
  2. <style>
  3. a,a:hover, img,img:hover{
  4.     position: relative;
  5.     display: inline-block;
  6. }
  7. a[data]:hover::after {
  8.     position: absolute;
  9.     top: 75% !important;
  10.     left: 50%;
  11.     transform: translateX(-50%);
  12.     content: attr(data);
  13.     background: ghostwhite;
  14.     padding: 5px;
  15.     z-index: 9999;
  16.     font-size: 11px;
  17.     display: block;
  18. }
  19. </style>
  20. JS
  21. <script>
  22. $(document).ready(function(){
  23.     $('a').each( function(){
  24.         if (typeof $(this).attr('title') !== typeof undefined && $(this).attr('title') !== false) {
  25.           $(this).attr('data', $(this).attr('title'));
  26.         }
  27.     });
  28.     $('img').each(function(){
  29.        if (typeof $(this).attr('alt') !== typeof undefined && $(this).attr('alt') !== false) {
  30.           $(this).attr('data', $(this).attr('alt'));
  31.         }  
  32.     });
  33. });
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement