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 8020793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:47:25+00:00 2026-06-04T21:47:25+00:00

Quick question here guys, I cant seem to get this $(‘#wrap’).on(‘toggle’, ‘#image’, function(){ <!–

  • 0

Quick question here guys, I cant seem to get this

$('#wrap').on('toggle', '#image', function(){
    <!-- Do stuff -->
  });

to be able to have a toggle inside it? Any ideas? I have tried googling but with no luck.

this is the code i am trying to get to work with .on, as currently it doesn’t apply the changes to all of the element son the page, (that have #image and #brick)

$("#result_options").toggle(function() {
        var image_width = $('#image').width() / 2;
        var brick_width = $('#brick').width() / 2;
        $("#image").css("width",image_width);
        $("#image").css("padding","4px");
        $("#brick").css("width",brick_width);
    },function (){
        $("#image").css("width","300");
        $("#image").css("padding","8px");
        $("#brick").css("width","314");
        $(this).html("Smaller Results");
    });
});
  • 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-04T21:47:27+00:00Added an answer on June 4, 2026 at 9:47 pm

    The problem you’re facing is that there is no toggle event; toggle() is a jQuery method. To implement a toggle(), with on() I think you’d need to use a click event, and then an if statement to test whether something’s been toggled on, or toggled-off/not-toggled

    $('#wrap').on('click', '#image', function(){
        if (!$(this).attr('data-toggled') || $(this).attr('data-toggled') == 'off'){
            /* currently it's not been toggled, or it's been toggled to the 'off' state,
               so now toggle to the 'on' state: */
               $(this).attr('data-toggled','on');
               // and do something...
        }
        else if ($(this).attr('data-toggled') == 'on'){
            /* currently it has been toggled, and toggled to the 'on' state,
               so now turn off: */
               $(this).attr('data-toggled','off');
               // and do, or undo, something...
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys got a quick question here, how do i set up TweetStream after
I have a quick question here. I know that the cakePHP find('first') function returns
Quick question, What have I done wrong here. The purpose of this code is
Quick question here about short-circuiting statements in C#. With an if statement like this:
just a quick question here. How can I add an image to my UIViewController.
Just a quick question here guys. I've been searching to no avail so far.
Another quick question here, I have this code: string sa[6] = { Fort Sumter,
This is just a quick Question. I am writing a feature here that creates
Hey guys.. Quick question: I wrote a simple JS that opens lightBox for image
Hopefully a quick question here. Can you use a function's returned value in a

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.