I'm not sure where I'm going wrong. I'm trying to create a very simple hover-enlarge plugin with Jquery using the scale function. Here is my code:
$(document).ready(function(){
$("#content img").toggle("scale",{
percent: "80%"
},0);
$('#content img').hover(function() {
$(this).css("cursor", "pointer");
$(this).toggle("scale",{
percent: "90%"
},500);
}, function() {
$(this).toggle("scale",{
percent: "80%"
},500);
});
});
Here's a small example: http://jsfiddle.net/8ECh6/
Here's the page: http://samples.zcardna.com/health.html
If somone knows where I've gone wrong that would awesome! THANKS!
Demo Link
Tutorial Link
This will show original dimensions of Image on Hover using jQuery custom code
HTML
CSS
jQuery
Well I'm not exactly sure why your code is not working because I usually follow a different approach when trying to accomplish something similar.
But your code is erroring out.. There seems to be an issue with the way you are using
scale
I got the jQuery to actually execute by changing your code to the following.But I have always done it by using
CSS
to setup my scaling and transition..Here is an example, hopefully it helps.
http://jsfiddle.net/y4yAP/
To create simple hover enlarge plugin, try this. (DEMO)
HTML
js
If you have more than 1 image on the page that you like to enlarge, name the id's for instance "content1", "content2", "content3", etc. Then extend the script with this, like so:
Edit: Change the "#content" CSS to: img[id^=content] to remain having the transition effects.