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

The Archive Base Latest Questions

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

I would like to have a function called in an onclick handler, within an

  • 0

I would like to have a function called in an onclick handler, within an IF statement… Confused?

I would be too, the code below should help… For some reason, I get "gotoIt is not defined" in FireBug.

I think people keep misunderstanding the question :P… the full code is below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- REQUIRE COMMON VARIABLE FILE -->
<? require 'sys/common.php'; ?>
<title><? echo $projectName; ?></title>
<link rel="stylesheet" href="css/reset.css" type="text/css" />
<link rel="stylesheet" href="css/screen.css" type="text/css" />

<script src="js/jquery-1.4.2.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {

        if ($(window).width()<1259) { //Small
            function gotoIt(x,y) {
                $('.elements').animate({
                    left: x+'px',
                    top: y+'px'
                }, 500, function() {
                });
            }
        } else { //Large
            function gotoIt(x,y) {
                $('.elements').animate({
                    left: x+'px',
                    top: y+'px'
                }, 500, function() {
                });
            }
        };

    });
</script>
</head>

<body onload="">
<!-- SITE CONTAINER -->
<div class="section">
    <!-- CENTRAL CONTAINERS -->
        <ul class="elements" style="height:4884px; width:6000px;">
            <li>1<br/><a href="#" onclick="javascript:gotoIt(1620,1130);">Next</a></li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li>10</li>
            <li>11</li>
            <li>12</li>
            <li>13</li>
            <li>14</li>
            <li>15</li>
            <li>16</li>
            <li>17</li>
            <li>18</li>
            <li>19</li>
            <li>20<a name="test"></a></li>
        </ul>
    </div>
</body>
</html>

And the CSS:

   body {
        font-family: arial;
        font-size: 62.5%;
        text-align: center;
        background-color: #fff;
    }

    /* CONTAINERS */
    div.section{
        border:1px black solid;
        width:100%;
        height: 100%;
        min-height: 100%;
        position:relative;
        clear:both;
    }
        div.section h3{
            margin-bottom:10px;
        }
        div.section li{
            float:left;
            vertical-align: middle;
        }
        div.pane{
            overflow:auto;
            clear:left;
            margin: 10px 0 0 10px;
            position:relative;
            width:826px;
            height:322px;
        }


    ul.elements{
        background-color:#5B739C;
        position:absolute;
        top:0;
        left:0;
    }
    ul.elements li{
        width:1280px;
        height:815px;
        font-weight:bolder;
        border:1px black solid;
        text-align:center;
        margin-right:200px;
        margin-bottom: 200px;
        background-color:#DDD;
        font-size: 100px;
    }

    #pane-options ul.elements li{
        margin:5px;
    }
  • 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-15T10:35:18+00:00Added an answer on May 15, 2026 at 10:35 am

    Define the function, then call it.

    function gotoIt(x,y) {
      $('.elements').animate({
        left: x+'px',
        top: y+'px'
      }, 500);
    }
    
    if ($(window).width()<1259) { //Small
      gotoIt(/* parameters here */);
    } else { //Large
      gotoIt(/* parameters here */);
    }
    

    Edit 3: is this what you want?

    $(document).ready(function() {
        if ($(window).width()<1259) { //Small
            (function(x, y) {
                $('.elements').animate({
                    left: x+'px',
                    top: y+'px'
                }, 500);
            })(20,20); //arguments x and y
        } else { //Large
            (function(x, y) {
                $('.elements').animate({
                    left: x+'px',
                    top: y+'px'
                }, 500);
            })(-20,-20); //arguments x and y
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((.+)/)?([^/]+)\.[^/.]+$ index.php?path=$2&file=$3 But… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer This query will return all the Type entities including subtypes,… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer You shoud try the dynaTrace Ajax IE profiler. Its awesome… May 16, 2026 at 5:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'd like to have a custom function repeatedly called as long as a custom
I have an onclick function which performs several tasks. In another JavaScript function I
I have called a function from a class to find all the items related
I have a list of elements I would like to be able to have
I have this layout: <div runat=server OnClick=ChangeText() id=button>Ok</div> <asp:UpdatePanel id=updater runat=server> <ContentTemplate> <div id=text>Hello</div>
I have written a function that takes two arguments and returns a SETOF result.
I have a couple of, what may end up being for this forum, overly-novice
I currently have form that checks if a user has unsubmitted changes when they
I have a form (signup.php) that pops up in a nyroModal window when I
I have a set of tabs which cause certain DIVs with options to 'fly

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.