jquery addClass () não funciona com event.target
Por favor ajude.
Por que o jqueryaddClass()
não está trabalhando comevent.target
? Eu criei um código e ele deveria adicionar classe ao destino quando clicado, mas não funciona e diz:e.target.addClass
não é uma função.
CÓDIGO:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Class Test</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<style>
.big {
font-size: 5em;
}
.small {
font-size: 1em;
}
</style>
</head>
<body>
<p>This is the text</p>
<script>
$(function() {
$("p").click(function(e) {
$("a").removeClass("big").addClass("small");
$("this").addClass("big"); //This doesn't work
e.target.addClass("big"); //nor this one
});
});
</script>
</body>
</html>