I need to get the main culpritClass
div class that holds everything after something is typed and enter is pressed and put it into a variable as a string.
I can't seem to get the class.
HTML:
<div class="culpritClass">
<div class="inner" style="display: block;">
<div class="inner_chat"></div>
<form>
<textarea class="chat_text"></textarea>
</form>
</div><a class="culpritClass" href="#">culprit</a>
</div>
I tried the following JS but I get undefined
.
$('.chat_text').keypress(function(e) {
if (e.keyCode == '13') {
var ru = $(this).prev().parent().attr('class');
alert(ru);
}
});
The var ru
is the line that matters.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…