<html>
<head>
<meta charset="utf-8">
<title>parent</title>
<script src="./js/jquery-1.4.2.min.js"></script>
<script>
function classify() {
//some jquery stuff here alredy, and it works...
//now I want to get/set the parent class, but not working (getting an alert with written "undefined", why?
var myclass = $(this).parent().attr('class');
alert(myclass);
}
</script>
</head>
<body>
<div class="pos">
<div class="classifyClass">
<div style="width:50px;height:50px;background-color:red;" onclick="javascript:classify();return false;"></div>
<div style="width:50px;height:50px;background-color:green;" onclick="javascript:classify();return false;"></div>
</div>
</div>
<div id="feedback"></div>
</body>
</html>
function classify(elem) {
//some jquery stuff here alredy, and it works...
var myclass = $(elem).parent().attr('class');
alert(myclass);
return false;
}