【发布时间】:2016-04-01 08:12:57
【问题描述】:
我想要一个箭头指向我的按钮,自动缩放并使用我在 Imgur 上上传的链接,但它不起作用。我有一个 if else 语句,它可以使用 unicode 图标,但是使用图像时它不起作用。我的代码有什么问题?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style type="text/css">
.button {
background: url("http://i.imgur.com/GKVoeGr.png") no-repeat 3px 5px;
}
</style>
</head>
<body>
<button style="width: 250px; height: 100px;" class="button">
</button>
<p>
<i>Content die weer te geven is bij het klikken van de knop.</i>
</p>
<script>
var toggled = false;
$("button").click(function() {
if (!toggled) {
$(this).html("http://i.imgur.com/Q2sj6XQ.png");
toggled = true;
} else {
$(this).html("http://i.imgur.com/GKVoeGr.png");
toggled = false;
}
$("p").slideToggle();
})
</script>
</body>
</html>
【问题讨论】:
标签: jquery html button imagebutton