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

  • Home
  • SEARCH
  • 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 872003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:43:17+00:00 2026-05-15T10:43:17+00:00

Hey all. Basically, I need (this) in my function to correspond to this selection:

  • 0

Hey all. Basically, I need “(this)” in my function to correspond to this selection:

$(".widget .portfolio img")

But I want alternative ways of running this function, one when it is cilcked, and one in intervals, like this:

function cycle()
{
  var poo = $(this).attr("id");
  $(".poo").html(poo);
}

    $(".widget .portfolio img").click(function() {
        cycle();
    });

    setInterval(function() {
        cycle();

    }, 4000);

});

The problem is that when the interval runs, the function’s value of “(this)” is that of the setInterval function – but I want it to be the selection I said above… if I could do something like this, it would be ideal:

setInterval(function() {
        cycle($(".widget .portfolio img"));
        ...

I think I just need a simple something in the function… any ideas? Thanks in advance 🙂

  • 1 1 Answer
  • 1 View
  • 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-05-15T10:43:18+00:00Added an answer on May 15, 2026 at 10:43 am

    pass a reference (or a jquery selector) to cycle.

    function cycle(obj)
    {
      var poo = obj.attr("id");
      $(".poo").html(poo);
    }
    

    or

    function cycle(sel)
    {
      var poo = $(sel).attr("id");
      $(".poo").html(poo);
    }
    

    then you can use either cycle($(".widget .portfolio img")) or cycle(".widget .portfolio img") according to which you prefer.

    My preference would be passing a reference, as I could then do this:

    $(".widget .portfolio img").click(function() {
            cycle($(this));
        });
    
        setInterval(function() {
            cycle($(".widget .portfolio img"));
    
        }, 4000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. Basically, I want the the next image to be clicked using jquery
Hey all, I basically output content into a div like this using jquery: var
Hey all, I've got a query in need of optimizing. It works but its
Hey all, basically i have an empty AS3 fla file with just the following
Hey all i am in need of some help getting my code working correctly
Hey all, I want to change a value in a table (in a mysql
Hey all. Basically I have a page full of text input fields with default
Hey, so basically I have this issue, where I'm trying to put an equation
Hey all, basically, i have an array: array('a', 'b', 'c'); Now i run it
Hey all. Quick question on Fluent syntax. I had thought I had this down,

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.