ANGULARJS Implement button hint and click Color Effect _ANGULARJS

Source: Internet
Author: User

This article with Angularjs simple implementation of a small button hint, button click will change color, note that the HTML file needs to introduce Jquery.js and angular.js

Run Screenshots:

The style of the button changes when the button is clicked:

CSS code:

<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 code:

<div ng-controller= "Buctipcontroller" >
 <!--directive--> <buc-button id= "numbertype"
 button " Tip-title = "This is the hint" style= "margin-top:60px;" ></buc-button>
</div>

JS Code:

<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=" Bucselectedbutt On bucselected ' ng-click= ' clicked () ' Ng-mouseover = ' mouseover () ' Ng-mouseout = ' mouseout () ' >{{mytitle}}\ <div s Tyle= ' 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;d isplay: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>

Mouse move into the button, tip tips appear, the mouse moved out when tip disappeared. Tip of the small triangle I was using the CSS3 attribute to achieve.

Summarize

The above is the entire content of this article, I hope to learn Angularjs can help. If you have any questions, you can exchange messages.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.