Solved

jQuery enlarge image on mouseover

Posted on 2012-04-08
2
654 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
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…

749 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