jquery的ajax后台后去数据的table切换
来源:互联网 发布:qt 调用dotnet 编程 编辑:程序博客网 时间:2024/05/29 07:03
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
span{
display: inline-block;
width: 100px;
height: 50px;
background-color: gray;
border: 1px solid red;
text-align: center;
line-height: 50px;
}
.main{
width: 410px;
height: 400px;
/*background-color: red;*/
position: relative;
}
.main img{
width: 410px;
height: 400px
}
.main p{
width: 410px;
height: 50px;
background-color: black;
opacity: 0.5;
text-align: center;
font-size: 20px;
line-height: 50px;
position: absolute;
bottom: 0;
color: white;
}
.img_div{
display: none;
}
</style>
</style>
</head>
<body>
<div class="show">
<div class="btn">
<span>第一块</span><span>第二块</span><span>第三块</span><span>第四块</span>
</div>
<div class="main">
</div>
</div>
</body>
<script src="js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript">
//后台获取数据
$.ajax({
url:'http://localhost/AJAX/php/img.php',
type:'post',
data:{type:''},
success:function(res){
console.log(res);
var arr= JSON.parse(res);
console.log(arr);
//创建节点加载图片
for(var i=0;i<arr.length;i++){
var myDiv=$('<div class="img_div"></div>');
myDiv.html('<img src="'+arr[i].url+'"><p>'+arr[i].title+'<p>');
$('.main').append(myDiv);
}
$('.img_div').eq(0).css({'display':'block'});
},
async:true
});
/*..................table切换.........................*/
//绑定按钮事件
$('span').on('click',function(){
$(this).css({'backgroundColor':'red'}).siblings().css({'backgroundColor':'gray'});
$('.img_div').eq($(this).index()).css({'display':'block'}).siblings().css({'display':'none'});
});
</script>
</html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
span{
display: inline-block;
width: 100px;
height: 50px;
background-color: gray;
border: 1px solid red;
text-align: center;
line-height: 50px;
}
.main{
width: 410px;
height: 400px;
/*background-color: red;*/
position: relative;
}
.main img{
width: 410px;
height: 400px
}
.main p{
width: 410px;
height: 50px;
background-color: black;
opacity: 0.5;
text-align: center;
font-size: 20px;
line-height: 50px;
position: absolute;
bottom: 0;
color: white;
}
.img_div{
display: none;
}
</style>
</style>
</head>
<body>
<div class="show">
<div class="btn">
<span>第一块</span><span>第二块</span><span>第三块</span><span>第四块</span>
</div>
<div class="main">
</div>
</div>
</body>
<script src="js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript">
//后台获取数据
$.ajax({
url:'http://localhost/AJAX/php/img.php',
type:'post',
data:{type:''},
success:function(res){
console.log(res);
var arr= JSON.parse(res);
console.log(arr);
//创建节点加载图片
for(var i=0;i<arr.length;i++){
var myDiv=$('<div class="img_div"></div>');
myDiv.html('<img src="'+arr[i].url+'"><p>'+arr[i].title+'<p>');
$('.main').append(myDiv);
}
$('.img_div').eq(0).css({'display':'block'});
},
async:true
});
/*..................table切换.........................*/
//绑定按钮事件
$('span').on('click',function(){
$(this).css({'backgroundColor':'red'}).siblings().css({'backgroundColor':'gray'});
$('.img_div').eq($(this).index()).css({'display':'block'}).siblings().css({'display':'none'});
});
</script>
</html>
阅读全文
0 0
- jquery的ajax后台后去数据的table切换
- easyui 中的 form 提交 后获得 后台 的 json数据 与 jquery .ajax的不同之处
- Jquery 使用Ajax获取后台返回的Json数据后,页面处理
- Jquery 使用Ajax获取后台返回的Json数据后,页面处理
- Jquery 使用Ajax获取后台返回的Json数据后,页面处理
- 通过Ajax请求后台数据,返回JSONArray(JsonObject),页面(Jquery)以table的形式展示
- bootstrap table ajax获取后台数据后js做判断
- 前台获取后台的数据,通过JSON后去后台的对象的数组
- AJAX传JSON处理后的数据至后台
- 用jquery实现ajax获取后台数据的示例
- jquery ajax 传数据到后台乱码的处理方法
- jQuery中的Ajax及其与Java后台的数据交换
- 通过jquery封装的ajax获取后台json数据
- jQuery实现的分页功能,包括ajax请求,后台数据
- (Jquery Ajax Call )Post 一个Form去后台以及AJAX call后DIV重新加载
- asp.net :使用jquery 的ajax +WebService+json 实现无刷新去后台值
- Bootstrap table的后台数据的获取
- 基于jQuery的AJAX请求Table显示
- 第一次课的笔记
- 对fflush(stdin)功能以及实际应用的个人体会,对初学者应该挺有用
- JAVA设计模式之责任链模式
- Js实现音乐播放控制条
- matlab2c使用c++实现matlab函数系列教程-rand函数
- jquery的ajax后台后去数据的table切换
- Apache优化
- javascript性能优化方面的知识总结
- Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers
- VB程序逆向常用的函数
- 342. Power of Four
- Koa2 —(2)
- SSM框架搭建
- 应用启动时间统计方法