0

I have a simple jQuery tooltip script:

http://jsfiddle.net/FFHnm/

it pulls the title tag in the link in the following line:

var title = jQuery(this).attr('title');

And inserts it into the tooltip in this bit:

.text(title)

Is it possbile to add html like a h2 to the title variable like so:

.text("<h2>" + title + "</h2>")

Thank you any help would be appreciated as i am very new to jQuery :)

2
  • Using html method, yes. Commented Jul 30, 2013 at 14:56
  • Side note: Refer to demos and api; you do not need to use .hover() and .mouseover() to control tooltip. Example: in place of .mouseover(), you can simply use track option. Commented Jul 30, 2013 at 14:57

2 Answers 2

1

Instead of using .text() you can use .html(), then you can set HTML as you are describing.

 .html('<h2>' + title + '</h2>);
Sign up to request clarification or add additional context in comments.

Comments

0

If I understand you correct, just change:

jQuery('<p class="ttip"></p>')

to

jQuery('<h2 class="ttip"></h2>')

in your javascript.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.