如何用js获得html标签中包含的内容
如果:<spanid="ss">中国</span>或者<liid="ls">上海</li>如何获得“中国”和“上海”这2个字????...
如果:<span id="ss">中国</span>或者<li id="ls">上海</li>
如何获得“中国”和“上海”这2个字???? 展开
如何获得“中国”和“上海”这2个字???? 展开
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function aa(){
var a = document.getElementById('sa');
var t = a.innerHTML;
alert(t);
}
</script>
<BODY>
<span id="sa">sdsaddad </span>
<input type="button" onclick="aa()" value="确定">
</BODY>
</HTML>
嘿嘿.......给分吧
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function aa(){
var a = document.getElementById('sa');
var t = a.innerHTML;
alert(t);
}
</script>
<BODY>
<span id="sa">sdsaddad </span>
<input type="button" onclick="aa()" value="确定">
</BODY>
</HTML>
嘿嘿.......给分吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery 单选选中设定</title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
</head>
<body>
<p>1</p><p>2</p><p>3</p>
<input type=button onclick="labelCount();" value="test">
<script>
function labelCount(){
var all = document.getElementsByTagName('p');
alert(all.length);
}
</script>
</body>
</html>
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery 单选选中设定</title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
</head>
<body>
<p>1</p><p>2</p><p>3</p>
<input type=button onclick="labelCount();" value="test">
<script>
function labelCount(){
var all = document.getElementsByTagName('p');
alert(all.length);
}
</script>
</body>
</html>
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询