最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AngularJS實現(xiàn)按鈕提示與點擊變色效果

 更新時間:2016年09月07日 10:52:52   作者:Jennry  
這篇文章給大家介紹了如何利用AngularJS實現(xiàn)按鈕提示與點擊變色的效果,文中提供了實例代碼,對大家學(xué)習(xí)AngularJS具有一定的參考借鑒價值,下面來一起看看吧。

本文用angularJS簡單實現(xiàn)了一個小的按鈕提示,按鈕點擊后會變色,注意html文件中需要引入jquery.js和angular.js

運行截圖:

當(dāng)點擊按鈕的時候 按鈕的樣式改變:

css代碼:

<style type="text/css">
  *{margin: 0px;padding: 0px;}
  .bucSelectedButton{width: 100px;line-height: 30px;text-align: center;position: relative;}
  .bucSelected {border:1px solid rgb(195,195,195);color:#000;cursor: pointer;border-radius: 6px;background-color: rgb(255,255,255);}
  .bucSelectedHover{border: 1px solid rgb(74,201,255);color: rgb(74,201,255);cursor: pointer;border-radius: 6px;background-color: rgb(238,249,254);}
  .bucSelectedHover .tip {color: rgb(0,0,0);background-color: rgb(255,255,255);}
 </style>

html代碼:

<div ng-controller="bucTipController">
 <!-- 指令 -->
 <buc-button id="numberType" my-title="按鈕" tip-title = "這個是提示" style="margin-top:60px;"></buc-button>
</div>

js代碼:

<script type="text/javascript">
var app = angular.module("tip",[]);
app.controller("bucTipController",function(){

})
.directive("bucButton",function(){
 return {
  restrict : 'E',
  replace : true,
  scope : {
   myTitle : "@",
   id : "@",
   tipTitle : "@"
  },
  template : "<button class='bucSelectedButton bucSelected' ng-click='clicked()' ng-mouseover = 'mouseover()' ng-mouseout = 'mouseout()'>{{myTitle}}\
    <div style='border:1px solid #dcdcdc;border-radius:6px;width:auto;height:20px;line-height:20px;position:absolute;top:-40px;padding:5px;white-space:nowrap;background-color:#fafafa;display:none;color:#000;left:20px;' class='tip'>{{tipTitle}}\
     <span style='position:absolute;top:25px;left:10px;background-color:#fafafa;border:1px solid #dcdcdc;width:10px;height:10px;transform:rotate(45deg);border-left:none;border-top:none;'>\
     </span>\
    </div>\
    </button>",
  link : function(scope,elem,attrs) {
   scope.mouseover = function(){
    $(".tip").show();
   }

   scope.mouseout = function(){
    $(".tip").hide();
   }

   scope.clicked = function(){
    elem.toggleClass("bucSelectedHover");
    $(".tip").hide();
   }
  }
 }
})
</script>

鼠標(biāo)移入按鈕,tip提示出現(xiàn),鼠標(biāo)移出的時候,tip消失。tip的小三角我是利用了css3的屬性來實現(xiàn)的。

總結(jié)

以上就是這篇文章的全部內(nèi)容,希望對大家學(xué)習(xí)AngularJS能有所幫助。如果有疑問大家可以留言交流。

您可能感興趣的文章:

相關(guān)文章

最新評論

迁安市| 延津县| 潮州市| 中西区| 长兴县| 玉树县| 张家界市| 长沙市| 罗城| 从化市| 睢宁县| 台中市| 罗定市| 越西县| 津南区| 九台市| 枝江市| 丹棱县| 高雄县| 麻阳| 孟津县| 宁强县| 大石桥市| 灵宝市| 滕州市| 深泽县| 晋州市| 乐亭县| 康平县| 兰西县| 扬州市| 宝坻区| 南开区| 民勤县| 吴桥县| 彩票| 鄯善县| 汪清县| 读书| 浪卡子县| 浏阳市|