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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:54:36+00:00 2026-05-23T03:54:36+00:00

I am trying to use SimpleBox jQuery plug-in on my website. I have the

  • 0

I am trying to use SimpleBox jQuery plug-in on my website. I have the code such that everytime the user clicks on a div of class “link”, a SimpleBox is invoked.

I also have another button that uses javascript to dynamically create divs of class “link” to my page. However, when I try to click these divs, the SimpleBox is not invoked.

    <script type="text/javascript">

        function createLinkDiv()
        {
            var parentDiv = document.getElementById ("right");
        var linkDiv = document.createElement("div");
            numDivs++;
            linkDiv.setAttribute("class","link");
            linkDiv.setAttribute("id",numDivs);

            parentDiv.appendChild(linkDiv);
        }

        $().ready(function() {

            $(".link").click(function(event) {
                event.preventDefault();
                $("#simplebox").simplebox();
            });  

            $(".close_dialog").click(function() {
                event.preventDefault();
                $("#simplebox").simplebox('close');
            });

        });

    </script>

Any idea why? Any help would be appreciated! Thanks!

  • 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-23T03:54:37+00:00Added an answer on May 23, 2026 at 3:54 am

    For Dynamically added items use .live() or .delegate() to attach event handlers

    $(".link").live("click",function(event) {
        event.preventDefault();
        $("#simplebox").simplebox();
    });
    

    Or

    $("#right").delegate(".link","click",function(event) {
         event.preventDefault();
         $("#simplebox").simplebox();
    }); 
    

    Out of context

    I suppose you’ve placed the the createLinkDiv function since you’re calling it through inline javascript. Calling functions via inline javascript is a bit of out of fashion these days. Binding those events in code helps to keep your javascipt code easily maintainable.

    $("#createLink").click(function(){
        $('<div/>').attr({"class":"link","id":"link_" + $(".link").size() }) 
                         //Id shouldn't start with a number (not in HTML5)
                   .click(linkClick)
                    //Now you don't have to use live
                   .appendTo("#right");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I am trying use the jQuery table sorter plugin for a table that is
Im trying use a Java annotation in a Groovy class but have trouble to
I'm trying use jquery to remove a class from an element (not knowing ahead
Hi I'm trying use a datepicker on a field I have. I'm trying to
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I have been trying use the edit_post_link() function to contain an image. All of
I am trying use filehelpers class builder but I am kinda confused on what
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char

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.