日期:2014-05-16 浏览次数:20383 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style type="text/css">
<!--
.p_info { width:100px; height:30px; background:#396; }
-->
</style>
<script type="text/javascript" src="http://www.csdn.net/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
var $test = $(".test").text();
if($test == "Error"){
$this.parent().siblings(".p_info").css("background","#000");
}
});
</script>
</head>
<body>
<div class="post">
<div class="post_info">
<div class="p_info"></div>
<div class="p_test">
<div class="test">Success</div>
</div>
</div>
</div>
<div class="post">
<div class="post_info">
<div class="p_info"></div>
<div class="p_test">
<div class="test">Error</div>
</div>
</div>
</div>
</body>
</html>
$(function(){
var test = $(".test").text();
alert(test);
if(test == "Error"){
$(".test").parent().siblings(".p_info").css("background","#000");
}
});