Solved

jQuery enlarge image on mouseover

Posted on 2012-04-08
2
611 Views
Last Modified: 2012-04-09
i'm trying to enlarge an image on mouse over and shrink on mouse out.



       <script type="text/javascript">
$(document).ready(function(){
    $('preview').mouseover(grow);
    $('preview').mouseout(shrink);
});

function grow(){
    $('img.preview').css('height','542px');
      $('img.preview').css('width','799px');
}

function shrink(){
    $('img.preview').css('height','65px');
      $('img.preview').css('width','100px');
}
</script>

                  
<body>
      


      <h3>Buy  - <?echo($Event." ".$Date)?> -       <img src="http://XXXXX/members/resources/images/image-1.jpg" id="preview" width="100px" height="65px" onmouseover="grow()" onmouseout="shrink()"> </h3>
      
            
        Any ideas why this isn't working as expected?
0
Comment
Question by:JPERKS1985
2 Comments
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 300 total points
Comment Utility
You should use # for id and . for class.
You have preview as an id.  Thus you should use 'img#preview' in your functions.

I am not sure but I think you are missing a semicolon at the end of your functions definitions grow() and shrink(); after the closing }
0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 200 total points
Comment Utility
<script type="text/javascript">
$('document').ready(function(){
    $('#preview').mouseover(grow);
    $('#preview').mouseout(shrink);
});

function grow(){
    $('#preview').css('height','542px');
      $('#preview').css('width','799px');
}

function shrink(){
    $('#preview').css('height','65px');
      $('#preview').css('width','100px');
}
</script>

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now