2

I'm doing a personal page in which I have to include some kind of tooltip in css like this

<a class="info" href="#">link<span>Your tooltip text here</span></a>

The css part:

a.info{
    position:relative;
    z-index:24;
    color:#000;
    text-decoration:none
}

a.info:hover{
    z-index:25;
    background-color: #FFF;
}

a.info span{
    display: none
}

a.info:hover span{
    display:block;
    position:absolute;
    top:2em; 
    left:2em; 
    width:15em;
    border:1px solid #000;
    background-color:#FFF;
    color:#000;
    text-align: justify;
    font-weight:none;
    padding:5px;
}

(I found the code on the net by the way)

I just wondered if in was possible to have the "your tooltip text here" in a text file, either by using html, or javascript and get it to display the text which is inside the text file.

I must not use php for this.

Thanks.

3 Answers 3

3

JavaScript can't read or write files ... But you can load the data from a text file with Ajax

1
  • I think @okayasu need separation of tool tip content to other file
    – yogs
    Commented Nov 14, 2010 at 5:36
1

You don't really need jQuery for this. You can create a js file with your content that looks like this

var tips = new Array(
    "My first tip",
    "My second tip"
);

Then just use whatever version of this function you want to load the file. BTW why not use the title attribute to simulate the tooltips: <a class="info" href="#" title="Your tooltip text here">link</a> Even if you want a fancy tooltip it seems better remove and then readd a title, rather than creating a whole separate element.

0

You can do this with ajax. Use jQuery because there are many examples available there.

3
  • 1
    Please use proper english. Or at least try.
    – jwueller
    Commented Nov 14, 2010 at 4:54
  • how to use jquery? does we have to include any header? I'm lost, i've not reached the chapters on jquery yet...
    – awlcs
    Commented Nov 14, 2010 at 5:32
  • Read docs.jquery.com/How_jQuery_Works This will give you good start. Then try link given above
    – yogs
    Commented Nov 14, 2010 at 5:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.