请帮忙.
为什么jquery addClass()不能使用event.target?我已经制作了一个代码,并且它应该在单击时在目标上添加类,但它不起作用,并且它说,e.target.addClass它不是一个函数.
码:
<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>
Run Code Online (Sandbox Code Playgroud) 我有mailto一些链接,允许用户通过将链接留空来手动输入收件人地址mailto,如下所示:
<a href="mailto:?subject='Article'">Share</a>
Run Code Online (Sandbox Code Playgroud)
但在 tenon.io 中测试时,它抱怨电子邮件地址为空:
我们有解决方法吗?