<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>在线相册管理</title> <link rel="stylesheet" type="text/css" href="css/photo.css"> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#add').on('click',function(){ //1.有效性验证 var img_url = $('#img_url').val() if (img_url.length == 0) { alert('请设置图片!') $('#img_url').focus() return false } //2.获取图片样式 var img_border = $(':radio:checked').val() //3.阴影 var shadow = 'none' if ($(':selected').val() == 1) { shadow = '3px 3px 3px #888' } //创建图片 var img = $('<img>') .prop('src',img_url) .width(150) .height(150) .css({'border-radius':img_border,'box-shadow':shadow}) //创建按钮 var btnPre = $('<button>').text('前移') var btnNext = $('<button>').text('后移') var btnDel = $('<button>').text('删除') var li = $('<li>').append(img,btnPre,btnNext,btnDel) li.appendTo('ul') //添加事件 btnPre.click(function(){ $(this).parent().prev().before($(this).parent()) }) btnNext.click(function(){ $(this).parent().next().after($(this).parent()) }) btnDel.click(function(){ $(this).parent().remove() }) }) }) </script> </head> <body> <div class="box"> <div class="info"> <h2>在线相册管理</h2> <p> <label for="img_url">请输入图片地址:</label> <input type="text" id="img_url" placeholder="images/demo.jpg"> </p> <p>请选择图片样式: <input type="radio" name="border" id="b1" value="0" checked><label for="b1">直角</label> <input type="radio" name="border" id="b2" value="10%"><label for="b2">圆角</label> <input type="radio" name="border" id="b3" value="50%"><label for="b3">圆形</label> </p> <p>图片是否添加阴影: <select name="shadow"> <option value="0" selected>不添加</option> <option value="1">添加</option> </select> </p> <p><button id="add">添加图片</button></p> </div> <div class="photo"> <ul></ul> </div> </div> </body> </html>
点击 "运行实例" 按钮查看在线实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>登录</title> </head> <body> <form action="api/login.php" method="post"> <fieldset> <legend>用户登录</legend> <p> <label>邮箱:</label> <input type="email" name="email" id="email"> </p> <p> <label>密码:</label> <input type="password" name="pw" id="pw"> </p> <p> <button>登录</button> <span id="tips" style="font-size:1.2em;font-weight:bolder;color:red"></span> </p> </fieldset> </form> </body> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $('button').eq(0).click(function(){ var url = 'api/user.php?m=login' var data = { "email":$('#email').val(), "password":$('#pw').val() } var success = function(res){ if (res == '1'){ $('#tips').text('登录成功,正在跳转中...') setTimeout(function(){ location.href = 'api/index.php' },2000) } else { $('#tips').text('邮箱或密码错误,请重新输入!') $('email').focus setTimeout("$('#tips').empty()",2000) } } var dataType = 'json' $.post(url,data,success,dataType) return false }) </script> </html>
点击 "运行实例" 按钮查看在线实例