jquery html
2016-01-15 16:44
549 查看
<!doctype html> <html> <head> <meta charset="utf-8"> <title>index.html</title> <script src="js/jquery-2.1.4.min.js"></script> <style> .blue{ color: blue; } #div1{ width: 200px; height: 150px; padding: 50px; margin: 20px; border: 2px solid #000; } </style> </head> <body> <div id="div1"></div> <p id="one">This is a paragraph.</p> <button onclick="appendText()">追加文本</button> <button onclick="removeElement()">删除元素</button> <button onclick="addClass()">添加类</button> <button onclick="setCss()">设置css属性</button> <button onclick="getSize()">获取尺寸</button> <script> function appendText(){ var txt1="<p>text1</p>"; var txt2=$("<p></p>").text("text2"); var txt3=document.createElement("p"); txt3.innerHTML="text3"; $("body").append(txt1,txt2,txt3); } function removeElement(){ $("p").remove(); } function addClass(){ $("p").addClass("blue"); } function setCss(){ $("#one").css({ "color":"red", "font-size":"15px" }); } function getSize(){ var txt=""; txt+="width: "+$("#div1").width()+"<br>"; txt+="height:"+$("#div1").height(); $("#div1").html(txt); } </script> </body> </html>
相关文章推荐
- jquery获取鼠标位置
- Jquery map用法
- Jquery each 用法
- Jquery 筛选
- JQuery经典例子:可拉伸菜单
- Jquery的一些简单使用记录
- 利用Jquery+JS生成Json串,动态创建添加项
- jQuery迭代器
- JQuery插件之ajaxFileUpload
- jquery ui 学习随笔 工具提示
- 封装jquery适配seajs模式
- JQuery Ajax
- Jquery 选择器
- jQuery 获取当前url各种信息
- django中使用jquery ajax post数据出现403错误的解决办法(两种方法)
- JQuery常用选择器
- JQuery点击复制文本框内容的方法插件
- jQuery + JavaScript 实现的动态添加文本框功能 和 动态删除文本框功能(二)
- for循环中的Ajax
- JQuery Mobile iscroll插件使用教程及注意事项