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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:11:22+00:00 2026-05-22T17:11:22+00:00

I have these 2 functions and would like 1 to execute the other with

  • 0

I have these 2 functions and would like 1 to execute the other with a specified variable:

function ckbmovestate() {
    $(this).css("-webkit-transform", "translate(53px, 0px)")

    };

function initcheckbox(){
    var togglebox = "<div class='toggle_box'><div class='switch'></div></div>";
    $('input[type=checkbox]').css('display','none');
    $('fieldset[data-input-type=checkbox]').append(togglebox);
    $('fieldset:has(:checkbox:checked)').each(function(){
        $(this).find('.switch').attr('data-state', 'on');
        ckbmovestate($(this))
    });
    $('fieldset:has(:checkbox:checked)')
    $('fieldset:not(:has(:checkbox:checked))').find('.switch').attr('data-state', 'off');

};

As you might guess, this does not work. Question is why? Could you give me a quick course on variable handling? Thanks guys, I know you are the best!

  • 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-05-22T17:11:23+00:00Added an answer on May 22, 2026 at 5:11 pm

    The simplest option is to define your function to take a parameter:

    function ckbmovestate(element) {
        $(element).css("-webkit-transform", "translate(53px, 0px)")
    }
    

    You can then call this with ckbmovestate(this) from your code.


    If you really want to be able to use the this keyword within a function when it’s called, you can do so. It’s not worth it here, but there may come a time when you want to do this. To achieve this, you need to make use of call or apply. Here, either would work:

    ckbmovestate.call(someElement);
    

    This sends the value of someElement to ckbmovestate. Inside ckbmovestate, you will be able to access the value using the keyword this. So in you code above, the following call would work:

    ckbmovestate.call(this);
    

    This is almost certainly overcomplicating things for this situation, however — much easier to define a parameter.

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

Sidebar

Related Questions

I have a javascript function that I would like to execute after every asynchronous
I have in my javascript these 2 functions classes: // product class function Product()
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
I have an iphone app where I call these three functions in appDidFinishLaunching: glMatrixMode(GL_PROJECTION);
I have looked at the documentation on MSDN about these 2 functions. However, I
I have 3 function in my class B. These three function have to access
i have custom cell with 2 buttons(the function of these buttons is just to
I have added a function to functions.php on my theme. function insertAds($content) { $content
So I have this database class in PHP and I only have 1 function
I have a query that looks something like this: select xmlelement(rootNode, (case when XH.ID

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.