I'm trying to create a button with icon like this:
HTML:
<div id='button'>
<div class='icon'></div>
<span>Send Email</span>
</div>
CSS:
#button {
width: 270px;
height: 50px;
font-size: 1.4em;
color: #333;
background-color: #555;
position: relative;
}
#button > .icon {
width: 61px;
height: 39px;
background-image: url('http://i55.tinypic.com/2agsutj.png');
background-repeat: no-repeat;
background-position: 0px 0px;
position: absolute;
left: 40px;
top: 5px;
}
#button > span {
position: absolute;
left: 130px;
top: 10px;
}
#button:hover {
color: #fff;
cursor: pointer;
}
JS:
$(function() {
$('#button').hover(function() {
$('#button > .icon').css('background-position', '0px -39px');
}, function() {
$('#button > .icon').css('background-position', '0px 0px');
});
});
My question is: Is Javascript really necessary for such simple functionality, or it can be done using CSS only ?