html:
<!DOCTYPE html> <html lang="en"> <head> <Meta charset="UTF-8"> <title>JQuery实例:浮动窗口</title> <script type="text/javascript" src="jslib/jquerywin.js"></script> <script type="text/javascript" src="jslib/jquery-3.1.1.js"></script> <link href="css/win.css" rel="stylesheet" type="text/css"> </head> <body> <a onclick="showWin()" href="#">显示窗口</a> <!--css改变div --> <div id="win">我的窗口<span id="close" onclick ="hide()">X</span></div> </body> </html>
js:
function showWin(){ var winNode = $("#win"); //通过jqurey修改css //winNode.css("display","block"); //使用jquery的show方法 winNode.fadeIn("slow");//淡入淡出fadeOut //winNode.show(4000); } function hide(){ var Node = $("#win"); //Node.css("display","none"); Node.hide("slow"); //或者是fadeout淡出 }
css:
/*#id id选择器*/ #win{ border: #ff1719 1px solid; border-radius:10px;/*控制高和宽*/ width: auto; height: auto; position: absolute; top: 200px; left: 200px; display: none; } #close{ cursor:pointer; }原文链接:https://www.f2er.com/ajax/161708.html