angular jQuery css html混合table表格查询 排序 添加 删除 隔行换色
来源:互联网 发布:手机淘宝充值中心 编辑:程序博客网 时间:2024/06/05 05:38
//第一步还是要导包
<script type="text/javascript" src="js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript" src="js/angular.min.js" ></script>
//head的布局和控制
<style type="text/css">
.xs{
cursor: pointer;
}
.first{
background-color:darkgrey;
}
tbody tr:nth-child(odd){
background-color:lightgrey;
}
tbody tr:nth-child(even){
background-color:azure;
}
table tr:hover{background-color:darkturquoise;
</style>
<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$(function () {
/* 表格第一行变 天蓝 色 */
$("thead tr").addClass("first");
});
$(function(){
$("button").addClass("xs");
})
//先在表格里添加一些数据
$scope.position = [{
name:"张三",
age:45,
pinyin:"zhang san",
zhiwei:"总经理"
},{
name:"李四",
age:43,
pinyin:"li si",
zhiwei:"设计师"
},{
name:"王五",
age:40,
pinyin:"wang wu",
zhiwei:"工程师"
},{
name:"赵六",
age:33,
pinyin:"zhao liu",
zhiwei:"工程师"
},{
name:"周七",
age:32,
pinyin:"zhou qi",
zhiwei:"人事经理"
}];
//过滤姓名
$scope.name = "";
$scope.flag = "";
$scope.flag2 = false;
$scope.filName = function(){
if($scope.name.indexOf("法轮功")>=0){
alert("不能包含敏感字符");
return false;
//$scope.flag = "";
}
if($scope.name == ""){
alert("请输入姓名");
$scope.flag = "";
}else{
for(index in $scope.position){
if($scope.name == $scope.position[index].name){
$scope.flag = $scope.name;
$scope.flag2 = true;
}else{
}
}
}
if(!$scope.flag2){
alert("没有找到匹配项");
}
}
//确定用户提交页面显示隐藏
$scope.isShow = false;
$scope.show = function(){
if($scope.isShow){
$scope.isShow = false;
}else{
$scope.isShow = true;
}
}
//验证age--->angular形式
$scope.newAge = "";
$scope.newName = "";
$scope.newPinyin = "";
$scope.newPos = "";
$scope.checkAge = function(){
if($scope.newAge == "" || $scope.newAge == null){
alert("年龄不能为空");
}else if(isNaN($scope.newAge)){
alert("年龄格式不正确")
}else if($scope.newAge<0 || $scope.newAge>150){
alert("输入的不是人的年龄")
}else{
var peo = {
name:$scope.newName,
age:$scope.newAge,
pinyin:$scope.newPinyin,
zhiwei:$scope.newPos
};
$scope.position.push(peo);
}
}
//点击删除按钮, 删除当前商品
$scope.delProduct = function(delName){
for(index in $scope.position){
if (delName == $scope.position[index].name) {
if(confirm("确定删除吗?") == true){
$scope.position.splice(index,1);
}else{
return false;
}
} else{
return false;
}
}
}
});
</script>
//下面数页面展示的布局
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>用户列表</h3>
用户名查询:<input type="text" ng-model="name"/>
<select ng-model="ageOrder">
<option value="">--请选择--</option>
<option value="age">年龄正序</option>
<option value="-age">年龄倒序</option>
</select><br />
用户列表<br />
<table border="1px solid blue" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>拼音</th>
<th>职位</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="pos in position | filter:flag | orderBy:ageOrder">
<td>{{pos.name}}</td>
<td>{{pos.age}}</td>
<td>{{pos.pinyin}}</td>
<td>{{pos.zhiwei}}</td>
<td><button ng-click="delProduct(pos.name)">删除</button></td>
</tr>
</tbody>
</table><br />
<button ng-click="filName()">查询</button>
<button ng-click="show()">添加用户</button><br /><br />
<div ng-show="isShow">
<h3>添加用户</h3>
用户名:<input type="text" placeholder="请输入用户名" ng-model="newName"/><br /><br />
拼 音:<input type="text" placeholder="请输入拼音" ng-model="newPinyin"/><br /><br />
年 龄:<input type="text" placeholder="请输入年龄" ng-model="newAge"/><br /><br />
职 位:<input type="text" placeholder="请输入职位" ng-model="newPos"/><br /><br />
<input type="button" ng-click="checkAge()" value="提交" />
</div>
</center>
</body>
- angular jQuery css html混合table表格查询 排序 添加 删除 隔行换色
- css+jQuery+angular+table查询排序添加和批量删除
- CSS控制表格Table隔行换色
- 隔行换色+模糊查询+添加+删除+排序
- angular js 循环数据(死数据) 添加数据 隔行换色 单个删除 排序
- CSS之Table表格隔行换色之简洁版
- jQuery实现table表格隔行换色鼠标经过变色
- jQuery实现table表格隔行换色鼠标经过变色
- table jquery angular删除添加排序
- table隔行换色 css
- css 表格隔行换色
- 隔行换色+删除+批量删除+排序+模糊查询+修改+添加
- jQuery表格隔行换色
- JQuery - 表格隔行换色
- 简单排序,单一删除,隔行换色,模糊查询,添加用户
- 表格(table)隔行换色
- Js、jQuery、angular隔行换色
- 表格隔行换色(CSS版)
- 利用GMP大整数库,实现ElGamal加解密
- centos6.8下mosquitto简介及搭建
- MathJax编辑指南
- 稳压电源 连载18:附录2 参数测量与特性图示
- rsync通过服务同步(下)
- angular jQuery css html混合table表格查询 排序 添加 删除 隔行换色
- cs231n笔记(3)—误差函数
- Duan2baka的Treap模板!
- python列表方法
- 【观察】晋级CNCF白金会员背后,阿里云为何如此看重开源?
- JavaEE_学习日记week01_eclipse的Tomcat的配置
- Java Simon--性能瓶颈分析工具
- Leetcode 3. Longest Substring Without Repeating Characters
- php5.6+Redis+Windows7安装 (phpstudy)