特殊情况下如何获取span里面的值
内容摘要
如何获取A? 复制代码 代码如下: <div class="warpper"> <span class="content"> A <span>123</span> </span> </div>
<script type='text/javascript' src='./jquery-1.7.2
<script type='text/javascript' src='./jquery-1.7.2
文章正文
如何获取A?
<div class="warpper">
<span class="content">
A
<span>123</span>
</span>
</div>
<script type='text/javascript' src='./jquery-1.7.2.min.js'></script>
<script type='text/javascript'>
var a = $(".content")[0].firstChild.data;
function al(){
alert(a);
}
window.onload=al;
</script>
复制代码 代码如下:
<div class="warpper">
<span class="content">
A
<span>123</span>
</span>
</div>
<script type='text/javascript' src='./jquery-1.7.2.min.js'></script>
<script type='text/javascript'>
var a = $(".content")[0].firstChild.data;
function al(){
alert(a);
}
window.onload=al;
</script>
代码注释