AngularJS如何實現鼠標移入顯示,鼠標移出隱藏的效果

在項目開發中,經常會用到鼠標移入顯示,鼠標移出隱藏的效果,在angularjs中,主要使用了ng-mouseenter與 ng-mouseleave 這兩個指令來實現鼠標的移入時顯示,移出時隱藏的效果。

示例如下:  

<!doctype html>
<html ng-app="plunker" >
<head>
  <meta charset="utf-8">
  <title>AngularJS Plunker</title>
  <script>document.write("<base href=\"" + document.location + "\" />");</script>
  <link rel="stylesheet" href="style.css">
  <script src="http://code.angularjs.org/1.1.0/angular.js"></script>
  <script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
  <span ng-mouseenter="show = true" ng-mouseleave="show = false">
    Mouse over me.
  </span>
  <br /><br />
  <div ng-show="show">Hello!</div>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章