改变鼠标上的背景图像 [英] changing the background image on mouse down
本文介绍了改变鼠标上的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个小问题,我发誓应该工作...它有点像一个愚蠢的问题...但这里是...
i想要一个div创建作为一个按钮...它是如何不想改变它的背景,当我点击它(给一个按钮的效果)
这里是我的代码:
I have a slight problem that I swear should work...it kinda seems like a silly question ...but here it is ... i want a div i created to act as a button ...it how ever does not want to change its background when i click on it( giving the effect of a button) here's my code :
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#button1 {
width:100px;
height:50px;
background-image:url(normalbutton.jpg)
}
</style>
</head>
<body class="asd">
<div id="container">
<a href="#">
<div id="button1" onmousedown="document.getElementById("button1").style.backgroundImage='url(onmousedownbutton.jpg)'"></div></a>
</body>
</html>
推荐答案
我认为使用jQuery会很容易: p>
I think using jQuery it will be easy :
$("#button1").mousedown(function() {
$(this).css({'background-image': 'url(1.jpg)'})
});
这篇关于改变鼠标上的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文