【发布时间】:2017-08-13 21:21:35
【问题描述】:
我有一个input 字段,我想在其文本上制作悬停效果:当鼠标在其上时,使其文本的底部边框变为彩色.
下面的代码使整个输入框的底部边框变成彩色的。
以下代码适用于value2,它不是input。
有谁知道如何处理输入中的文本,而不是输入字段?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<style>
input {
font-size: 20px;
border:none;
display: inline-block;
background-color:transparent;
}
.item {
font-size: 20px;
display: inline-block;
}
input:hover, .item:hover {
border-bottom: 2px solid #42b983;
}
</style>
</head>
<body ng-app="app" ng-controller="Ctrl">
<input type="text" ng-model="value1">
<br/>
<div class="item">{{value2}}</div>
<script>
var app = angular.module('app', []);
app.controller('Ctrl', ['$scope', function ($scope) {
$scope.value1 = "value1";
$scope.value2 = "value2"
}])
</script>
</body>
</html>
【问题讨论】:
标签: javascript jquery css angularjs html-input