Place ID inside a TITLE

Asked

Viewed 206 times

0

I need to put an id in an example title

<div title="<span id=""></span>"> </div>

But I didn’t get a result, some way I could do that function?

  • 1

    What is your intention to put a tag inside an attribute of another tag ?

  • I have a . load function, that when I click on a certain div it puts new data inside the title

  • In case, when you click on a div "x" it will update the title of the div with some information is this?:

  • That’s right clicked on a div X it updates the div title

2 answers

1


you can use the attr() to access the title attribute and put the new value, and then use it to pick up again, example:

$("div").click(function() {
  $("div").attr('title', 'Meu Título'); // coloca a informação na div
  alert($("div").attr('title')); // recupera o valor

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div title="">Clique na DIV</div>

  • after you load the html file this html will become part of your current html, so you search where the text you want and find a selector that can take the value of that text.

  • Here an example, in the function animaLoad I call a load to load an external text file that has a title and when it is loaded I give an Alert: http://jsfiddle.net/x8e6mpks/2/

0

It is not possible to put a id or class within a title, or even HTML. The attribute title="" serves only to specify additional information to a single element.

However if your intention is to customize the attribute title, you can do it this way:

#meuTitulo {position: relative;}

#meuTitulo[title]:hover:after {
  content: attr(title);
  color: #fff;
  position: absolute;
  left: 0;
  top: 100%;
  padding: 4px 8px;
  z-index: 20;
  white-space: nowrap;
  background-color:royalblue;
}
<a href="#" id="meuTitulo" title="Olá, eu sou um link!">StackOverflow</a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.