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

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

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

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

運(yùn)行截圖:

當(dāng)點(diǎn)擊按鈕的時(shí)候 按鈕的樣式改變:

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 = "這個(gè)是提示" 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)移出的時(shí)候,tip消失。tip的小三角我是利用了css3的屬性來(lái)實(shí)現(xiàn)的。

總結(jié)

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

相關(guān)文章

最新評(píng)論

隆回县| 永城市| 永济市| 怀宁县| 临桂县| 德化县| 调兵山市| 延吉市| 扎赉特旗| 湟源县| 西和县| 安化县| 成武县| 利辛县| 遵化市| 中牟县| 上杭县| 苍梧县| 夏河县| 建瓯市| 托里县| 海安县| 漳平市| 滦南县| 绿春县| 朔州市| 江永县| 珠海市| 淮阳县| 常德市| 孙吴县| 珠海市| 馆陶县| 钦州市| 石河子市| 文登市| 邳州市| 鄱阳县| 长治县| 泰兴市| 桃源县|