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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:22:37+00:00 2026-05-29T12:22:37+00:00

i am bit new to jQuery and I am trying to add a jQuery

  • 0

i am bit new to jQuery and I am trying to add a jQuery UI button on my appended list.
Here is the code I used, which of course; does not work πŸ™

I hope someone can help me with this thanks. πŸ™‚

<ul></ul>
<button id="Add" type="button">Add</button>

<script>
    $(document).ready(function () {
        $("#Add").button({
            icons: {
                primary: "ui-icon-plusthick"
            },
            text: true
        });

        $("#Add").click(function () {
            $("ul").append("<li>"
                         + "<span>SOME TEXT</span>"
                         + "<button class='Remove' type='button'>Remove</button>"
                         + "</li>");
            return false;
        });

        $(".Remove").button({
            icons: {
                primary: "ui-icon-minusthick"
            },
            text: true
        });
    });
</script>
  • 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-29T12:22:42+00:00Added an answer on May 29, 2026 at 12:22 pm

    This:

    $(".Remove").button({
        icons: {
            primary: "ui-icon-minusthick"
        },
        text: true
    });
    

    only applies to .Remove elements that are in the DOM when you call $('.Remove').button(...) and there aren’t any .Remove elements when you call it. You want to merge that into your #Add handler so that new buttons will be jQuery-UI-ified when they’re created. Something like this:

    $("#Add").click(function() {
        var $li = $('<li><span>SOME TEXT</span><button class="Remove" type="button">Remove</button></li>');
        $li.find('button').button({
            icons: { primary: 'ui-icon-minusthick' },
            text: true
        });
        $("ul").append($li);
        return false;
    });
    

    Demo: http://jsfiddle.net/ambiguous/fu9e9/

    And for your (probable) next question, you’ll want to use $(document).on(...) to hook up the “remove” buttons:

    ​$('ul').on('click', '.Remove', function() {
        $(this).closest('li').remove();
    });​​​​​​​​
    

    Demo: http://jsfiddle.net/ambiguous/fu9e9/2/

    That will hook the callback function up to all existing and future .Remove elements.

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

Sidebar

Related Questions

Thanks for reading. I'm a bit new to jQuery, and am trying to make
i am a bit new to using jquery, the following should display a button,
I'm trying the new data-function in jQuery but can't make it work. Here is
I have the following bit of code. I'm trying to dynamically add drop-down options
I am a bit new to jQuery, and trying to learn it. I am
Im new to Jquery but it turns out I used it quite a bit
I am a bit new to reusable plugins for jquery. I have ran across
I'm new to Rails and I know a bit of Jquery. I need a
I am a bit new to Perl, but here is what I want to
I'm a bit new to Papervision3D, and I'm trying to set the alpha level

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.