我想在JavaScript中將鼠標移到圖像上時顯示文本。我不知道我要去哪裏,因爲我是新手。有一張表格,當我將鼠標移到圖片上時,我想要顯示其內容。我想在這裏使用JavaScript。我想在JavaScript中將鼠標移到圖像上時顯示文本
<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>
我只想.Probably顯示圖像的頂部的文本的簡要說明一個圖像。 – jeny
您可以將Div放置在圖像上方。然後它會出現在圖像上方。如果文本和圖像從數據庫中提取並需要顯示每個圖像的不同文本,則需要修改上述代碼。但邏輯是一樣的。 –
感謝它的工作。有什麼方法可以移動文本嗎?它顯示在頂部。我希望它在圖像上或圖像旁邊。 – jeny