html怎么实现鼠标放在文字上显示文字(附带代码)?

html-css010

html怎么实现鼠标放在文字上显示文字(附带代码)?,第1张

实现鼠标悬停显示文字,html中使用title属性就可实现显示文字的效果,这个属性还是比较实用的,你可以参考下

<a href="#" title="这里是显示的文字">hello</a>

当鼠标悬停在 hello上一会就会有文字 "这里是显示的文字" 显示。

<!DOCTYPE html>

<html>

  <head>

    <title>文件示例</title>

    <meta name="name" content="content" charset="utf-8">

  </head>

  <body>

      <input type="file" id="file" />

      <input type="button" onclick="readText()" value="File Button">

      <div id="tt">

  

      </div>

  </body>

</html>

<script charset="utf-8">

window.onload=function () {

  if(typeof(FileReader)=="undefined")

  {

    alert("你的浏览器不支持文件读取")

    document.write("")

  }else

  {

    alert("你的浏览器支持文件读取")

  }

}

  function readText() {

      var file=document.getElementById("file").files[0]

      var reader=new FileReader()

      reader.readAsText(file)

      reader.onload=function(data)

      {

        var tt=document.getElementById("tt")

        tt.innerHTML=this.result

      }

    }

  

</script>