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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:44:41+00:00 2026-06-17T01:44:41+00:00

Language: jQuery / Javascript / PHP I am trying to show a hidden DIV

  • 0

Language: jQuery / Javascript / PHP

I am trying to show a hidden DIV once a user clicks on a link.

There are 3 types of actions that should take place, depending on the value inside data-action attached inside the href tag.

It has 3 possible values:

  • shake
  • bounce
  • default (my problem)

Now using switch, I switch through these actions in the Javascript code.

My problem is, I can’t show the hidden div I am trying to target (code under default is where I’m running into some trouble with).

JSfiddle: http://jsfiddle.net/ryxcw/1/ (problem starts at line 59)

Javascript code in use:

function loadBubbleActions() {
  $('#container > a').each(function () {

    switch ($(this).attr('data-action')) {
      case "shake":
        //bind shake action to bubble
        $(this).live("click", function (e) {


          var props = $.parseJSON($(this).attr('data-action-properties'));
          var ox = $(this).css('left').replace('px', '');
          var oy = $(this).css('top').replace('px', '');
          if ($('#tae').length == 0) {

            var overlay = jQuery('<div id="overlay" style="background-color: #fff !important; background-image: url(images/texture-shake.jpg);"> </div>');
            overlay.appendTo(document.body)

            $(document.body).append('<div id="tae" class="shake" style="position:absolute;opacity:1;z-index:12000;">Info goes here</div>');

            $('#overlay').click(function () {

              $('#overlay').remove();
              $('#tae').remove();

            });


            var cssWidth = ($(this).css('width').replace('px', '') / 2 - 20);
            var cssHeight = ($(this).css('height').replace('px', '') / 2 - 20);
            var ss = ($(window).width() / 2);
            var dd = ($(window).height() / 2);

            $('#tae').css('left', (ss - cssWidth) + "px");
            $('#tae').css('top', (dd - cssHeight) + "px");


            $('#tae').effect("shake", {
              times: 5
            }, 500);
          } else {
            $('#tae').effect("shake", {
              times: 5
            }, 500);

          }
        });

        break;



      case "bounce":
        //do specific action stuff here

        $(this).live("click", function (e) {
          alert("This is a bouncing post " + $(this).attr('data-link'));
        });
        break;
      default:
        //do action code for default here
        $(this).live("click", function (e) {

          divID = $(this).attr('id');

          var props = $.parseJSON($(this).attr('data-action-properties'));
          var act = $(this).attr('data-action');
          var ox = $(this).css('left').replace('px', '');
          var oy = $(this).css('top').replace('px', '');
          if ($('.panda').length == 0) {

            $("#theDIV-" + divID).show();
            $("#overlay").show();

            $('#overlay').click(function () {

              $('#overlay').remove();
              $('.panda').remove();

            });


            var cssWidth = ($(this).css('width').replace('px', '') / 2 + 400);
            var cssHeight = ($(this).css('height').replace('px', '') / 2 - 20);
            var ss = ($(window).width() / 2);
            var dd = ($(window).height() / 2);

            $('.panda').css('left', (ss - cssWidth) + "px");
            $('.panda').css('top', "100px");
          } else {
            //$('#tae').effect("shake", { times:props.shakeNumber }, 200);
          }

        });
    }
  });
}

I really hope someone would be able to help out, I’ve spent the entire night nitpicking on this thing, I could really use the guidance. Thank you so much for your time!

Once again, here is a JsFiddle for your convenience —
JSfiddle: http://jsfiddle.net/ryxcw/1/ (problem starts at line 59)

  • 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-17T01:44:42+00:00Added an answer on June 17, 2026 at 1:44 am

    You’re doing this

    if ($('.panda').length==0) {
          $("#theDIV-" + divID).show();
    

    but $('.panda').length returns 1 because

    <div class="panda hiddenDIV" id="theDIV-77" style="position:absolute;z-index:12000;">This is the content</div>
    

    exists so the action $("#theDIV-" + divID).show(); won’t run.

    http://jsfiddle.net/ryxcw/2/

    ASIDE

    Where you’ve used $(this).live() you should have used $(this).on() (though live will still work there).

    You’re using data wrong. data-action="something" is stored in the DOM on run. You access its contents using .data('action') not .attr('data-action')

    Also I have to agree with Pointy, kind of. There’s not so much “a lot of things wrong with the code” but rather, you’re doing a lot of things wrong.

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

Sidebar

Related Questions

I'm trying to redo this in jQuery: <script language=JavaScript type=text/javascript> var thisIsSelected = '<?php
I'm trying to dynamically add elements to a Cakephp form: <?php echo $javascript->link('jquery',false); ?>
I'm trying a simple if/else statement with Javascript & PHP (with jQuery cookie plugin
Language: PHP and jQuery What I'm trying to do is pop up a dynamic
Language: OO PHP 5+ DB: MySQL I am trying to insert data from a
I am trying to use javascript, without framework(prototype, jQuery,etc), to insert data passed from
I am having an issue with ZEND, JQuery, PHP, and Javascript. I am very
I'm trying to implement a jQuery AJAX script to open a link in a
I'm making a site in two language ,I want to give a jquery Modal
Language: PHP / MySQL I am going out of my mind, I really have

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.