Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8093355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:29:14+00:00 2026-06-05T20:29:14+00:00

I wrote code first without using functions to prototype, and of course, it worked

  • 0

I wrote code first without using functions to prototype, and of course, it worked fine:

$(function() {
    $(".PortfolioFade img")
        .mouseover(function() { 
            popup('PORTFOLIO');
            var src = $(this).attr("src").replace("images/paperclip.png", "images/paperclip-black.png");
            /*var src = $(this).attr("src").match(/[^\.]+/) + "-black.png";*/
            $(this).attr("src", src);
        })
        .mouseout(function() {
            ;
            /*var src = $(this).attr("src").replace("images/paperclip-black.png", "images/paperclip.png");
            $(this).attr("src", src); Look at popup.js mouseover events*/ 
        });
    });

However, when I expressed the same in function form, the function call didn’t seem to work.

$(document).ready(function() {
   // put all your jQuery goodness in here.
   $('body').hide().fadeIn(1000);

    function ImageRollover(image_element, popup_name, original, replacement)
{
    $(element)
        .mouseover(function(){
            popup(popup_name);
            var src = $(this).attr("src").replace(original,replacement);
            $(this).attr("src",src);

        })
        .mouseout(function(){
            ;
        });
}

   ImageRollover(".Portfolio img",'PORTFOLIO',"images/paperclip.png","images/paperclip-black.png"); 
 });

Defining the function elsewhere didn’t seem to have any effect either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:29:15+00:00Added an answer on June 5, 2026 at 8:29 pm

    Your function is defining the first variable as image_element, but you’re referring to it as just element in the code. That’s quite likely one factor to it not working.

    You’ll likely also encounter an issue with the keyword this inside your function. It isn’t referring to the same object as in the original code (which jQuery sets to the HTML element for you). In your function, it is likely not being set to anything thus it’s a link to window.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created c++ dll (using mingw) from code I wrote on linux (gcc), but
I am trying to write some of my first code in emacs lisp and
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to write some code to remove the first N characters in a
I'm writing HTML code for a Java servlet. I first write the code in
I wrote code to get name of printer which is installed in my system.but
I recently wrote code that didnt work as i would expect, it was: message
i added sharekitkit my project. And wrote code like here : SHKItem *item =
I wrote some code in VHDL that is expected to look at a rotory
I wrote this code for zoom in/out . it works but even with one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.