Solved

jQuery enlarge image on mouseover

Posted on 2012-04-08
2
668 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 300 total points
ID: 37821394
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
ID: 37821572
<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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

729 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