There is html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Tooltip</title> <link rel="stylesheet" href="css/css_tooltip.css"> <link rel="stylesheet" href="css/jquery-ui.min.css"> </head> <body> <div id="main"> <div class="color_box"> <a href="#" class="radio" style="background-color: #FFFFFF;" title="Алюминий"> <input type="radio" name="color" style="opacity: 0;"> </a> <a href="#" class="radio graize" style="background-color: #F5F5DC; " title="Бежевый" > <input type="radio" name="color" style="opacity: 0;"> </a> <a href="#" class="radio" style="background-color: #964B00; " title="Коричневый" > <input type="radio" name="color" style="opacity: 0;"> </a> <a href="#" class="radio graize" style="background-color: #98FB98; " title="Светло-зеленый" > <input type="radio" name="color" style="opacity: 0;"> </a> </div> <div class="box_b"> <a href="/cat/000088602" class="radio radio3 radio_act graize"> <input type="radio" name="filter_second" style="opacity: 0;"> 1 </a> <a href="/cat/000088602" class="radio radio3 radio_act"> <input type="radio" name="filter_second" style="opacity: 0;"> 2 </a> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript" src="tooltip/jquery.js"></script> <script type="text/javascript" src="tooltip/jquery-ui.min.js"></script> <script type="text/javascript" src="tooltip/jquery-ui.js"></script> <script type="text/javascript" src="tooltip/tooltip.js"></script> </body> </html> 

Code written for tooltipa

 $('.graize').tooltip({ track: true, items: 'a', show: { effect: "blind"}, content: function() {return "Привет" + " " + $(this).attr('title');} }); 

It works, if there is a class graize, for colors it displays everything as it should, but for a link in which the number is "Hi undefined", how to get the value out of the a tag?

  • one
    Well, where there are numbers, you do not specify the title. and in the script you access it directly (title) - Yury Kopot
  • Naturally the title is undefined , the links do not have this attribute - yolosora

1 answer 1

Thank you, I decided the question.

 {return "Недоступно в" + " " + $(this).text();} 

It seems to work)