Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  95] [ 7]  / answers: 1 / hits: 22804  / 8 Years ago, fri, february 26, 2016, 12:00:00

I want to display text when I move mouse over image in JavaScript. I don't know where I am going as I am new to this.There is a table which has images I want to display its content when I move mouse over image . I want to use JavaScript here.



<script>
function show()
{
var welcome = document.getElementById('sub1');
welcome.style.display = 'block';
}

function hide()
{
var welcome = document.getElementById('sub1');
welcome.style.display = 'none';
}
</script>

<div id=sub1 onmouseover=show(); onmouseout=hide();> </div>

//This is the image where I want to display a text.
<td><img border=0 src=images/img1.jpg
alt=iphone 5s width=304 height=228></td>

More From » jquery

 Answers
33

Do you want to replace the text with image or place text somewhere else ?
From my understanding , please check below code :



    <script>
function showText(text){
document.getElementById(text).innerHTML=text;
}
function hide(){
document.getElementById(text).innerHTML=;
}
</script>
<img src=image.jpg id=image onMouseOver=showText('Some Text') onMouseOut=hide();>
<div id=text></div>

[#63154] Wednesday, February 24, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyquandaquanl

Total Points: 122
Total Questions: 109
Total Answers: 101

Location: South Georgia
Member since Sun, Aug 8, 2021
3 Years ago
;