运行代码 缩小
喵记
HTML代码
复制 格式化 注释 注释 清空
放大
x
 
1
<!DOCTYPE html>
2
<html>
3
    <head>
4
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
5
        <script type="text/javascript" src="//apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js">
6
        </script>
7
    </head>
8
    <body>
9
        dom获得对象,给设置innertext : 
10
        <span id = "s1">
11
        </span>
12
        </br>
13
    jquery获得对象,给设置内容 : 
14
    <span id = "s2">
15
    </span>
CSS代码
复制 格式化 注释 注释 颜色 清空
放大
xxxxxxxxxx
14
 
1
body {
2
    background-image: url(/themes/zhan/styles/images/bg-body.jpg);
3
}
4
.main {
5
    width: 80%;
6
    margin: auto;
7
    text-align: center;
8
    border: 1px solid #e0e0e0;
9
    box-shadow: 0 0 2px #ddd;
10
    word-wrap: break-word;
11
    padding: 10px;
12
    border-radius: 3px
13
}
14
JS代码
复制 格式化 注释 注释 清空
放大
xxxxxxxxxx
30
 
1
window.onload = function(){
2
document.getElementById("s1").innerText = "aaaa,s1";
3
}
4
$(document).ready(function (){
5
$("#s2").text("bbbb,s2");
6
});
7
8
$(document).ready(function(){
9
$("span")[2].innerText = "cccc,s3";
10
});
11
12
$(document).ready(function (){
13
$("span").get(3).innerText = "dddd,s4";
14
});
15
16
$(document).ready(function(){
17
  $("#btn").click(function(){
18
    alert($("#s5").attr("style"));
19
  });
20
});
21
$(document).ready(function (){
22
    $("#bian").click(function (){
23
        $("#s6").attr("style","color:red");
24
    });
25
});
26
27
28
29
30
名称
9.4jquery
分类
jQuery实例
描述
获得对象的方法,j和d对象互相转换,得到和设置html属性
收藏