Results 1 to 4 of 4

Thread: Set a mouseover image effect using jQuery

  1. #1
    Join Date
    Jan 2009
    Posts
    110

    Set a mouseover image effect using jQuery

    I am having query related to jQuery i have created a html code where i am trying to have a image displayed whenever a mouse is being movedover any hyperlink.I know that this kind of things we can do it by using JQuery but don't know how to do it can anyone provide me the code or any ideas where i can make this thing happening.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: jquery image mouseover

    Try to use the following code to set image effect on mouseover

    HTML Code:
    <style type="text/css">
    #demo_this 
    {
          list-style-type: none;
          }
        
    </style>
    <script type="text/javascript">
    
    $(document).ready(function(){
    
    $(function() {
      $("#demo_this img").hover(function() {
            $(this).attr("src", $(this).attr("src").split(".").join("-hover."));  // adds -hover to the name of the image
      }, function() {
            $(this).stop(true,false); // prevents the creation of stacked actions
            $(this).attr("src", $(this).attr("src").split("-hover.").join("."));  // removes -hover from the name of the image
      });
    });
    
      }); // end docready
    </script>
    
    <h1> Abbreviated Method Calls</h1>
    <p>From: <a target="_blank" href="http://www.techarena.in">JQuery Rollovers Using  this </a></p>
    <p>This is simple rollover done easier in CSS </p>
    <p> &nbsp; </p>
    
    <ul id="demo_this">
          <li><a href="#"><img src="/images/item1.gif" border="0" /></a></li>
          <li><a href="#"><img src="/images/item2.gif" border="0" /></a></li>
          <li><a href="#"><img src="/images/item3.gif" border="0" /></a></li>
    </ul>

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Mouseover image effect using jQuery

    Try to use the following code by using jQuery where image effect is not there

    HTML Code:
    <html>  
    <head>  
       <script type="demotext/javascript" src="jquery.js"></script>  
       <script type="demotext/javascript">  
          $(function() {  
             $('table tbody tr').mouseover(function() {  
                $(this).addClass('selectedRow');  
             }).mouseout(function() {  
                $(this).removeClass('selectedRow');  
             }).click(function() {  
                alert($('td:first', this).text());  
             });  
          });  
       </script>  
       <style>  
          .selectedRow {  
             background-color: red;  
             cursor: pointer;  
          }  
       </style>  
    </head>  
    <body>  
       <table border="2">  
          <thead>  
             <tr>  
                <th>1st Column</th>  
                <th>2nd Column</th>  
                <th>3rd Column</th>  
             </tr>  
          </thead>  
          <tbody>  
             <tr>  
                <td>First </td>  
                <td>d1</td>  
                <td>d2</td>  
             </tr>  
             <tr>  
                <td>Second</td>  
                <td>d3 </td>  
                <td>d4</td>  
             </tr>  
          </tbody>  
       </table>  
    </body>  
    </html>

  4. #4
    Join Date
    Mar 2009
    Posts
    89

    Re: Set a mouseover image effect using jQuery

    Try to use a style rule for mouseover, where you add the class to the element on which the event is bound.

    HTML Code:
    <style type="text/css">
    img.mouseover
    {
        border: medium none;
        border-bottom: 2px solid;
    }
    </style>
     
    <script type="text/javascript">
    $(function() {
        $(".view-thumb img").mouseover(function() {
            // get rid of the text decoration on all 4 thumbnails by removing the class
            $("img.mouseover").removeClass("mouseover");
            // add the class to the specific image
            $(this).addClass("mouseover");
        });
    });
    </script>

Similar Threads

  1. My jquery is not working for an image mouse hover?
    By Bontu in forum Software Development
    Replies: 4
    Last Post: 10-06-2011, 07:30 AM
  2. How to add Mock Effect in an image
    By Kalanidhi in forum Windows Software
    Replies: 5
    Last Post: 18-04-2010, 01:11 AM
  3. How can i apply Speed Effect to image in Photoshop
    By teenQ in forum Windows Software
    Replies: 5
    Last Post: 20-01-2010, 01:46 AM
  4. Image changing on mouseover
    By Shophia_D in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 09:34 PM
  5. How to make an image blink effect using photoshop?
    By biohazard 76 in forum Windows Software
    Replies: 2
    Last Post: 01-08-2009, 06:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,394,392.33794 seconds with 16 queries