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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:42:46+00:00 2026-05-26T01:42:46+00:00

Initially, when users click the delete button, I want the whole line of elements

  • 0

Initially, when users click the delete button, I want the whole line of elements are removed.

This is for adding a line of elements when add button is being pressed:

function btnPlsClickEvent(btn){
btn.remove(".buttonPlus");
$(".buttonMinus").show();
//$("#q" + questionCount).append("<p id='q'+ '" + ++questionCount + "' + ''>Question: " + questionCount + "<input type='text'>\
$("#q1").append("<p id='q'+ '" + ++questionCount + "' + ''>Question: " + questionCount + "<input type='text'>\
<button type='button' class='buttonPlus'></button>\
<button type='button' class='buttonMinus' id='"+ questionCount +"'></button></p>");

$(".buttonMinus:last").hide();  

//Because it's dynamically appended, I re-bind them in this way:
//Re-binding
var newBtnPlus = $(".buttonPlus:last");
var newBtnMinus = $(".buttonMinus:last");
newBtnPlus.click(function(){
    btnPlsClickEvent(newBtnPlus);   //ATTENTION!
});
newBtnMinus.click(function () {
    btnMnsClickEvent(this);     //ATTENTION! Is it passing btn which is at the head of the function? If so, it should refer to Plus button.
});

alert("Add a question.");}

So, if I want to delete the whole line, I should find its parent

and call .remove().

function btnMnsClickEvent(btn) {
alert("You have deleted #" + btn.id + " question.");
btn.parent().remove();}

The question #1 is: I can correctly get the id of the minus button, using btn. But how come I can’t refer to itself or its parent and remove it?

Q #2 is: Why I can remove btn’s class at the head of btnPlsClickEvent() but I can’t do so in btnMnsClickEvent()? I know I am using two different ways to pass different object to btnPlsClickEvent() and btnMnsClickEvent(). What’s the differences of them?

Thank you very much,
Ashley

  • 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-26T01:42:47+00:00Added an answer on May 26, 2026 at 1:42 am

    1# Try to change your remove() line to:

    $( btn ).parent().remove();
    

    The function get object of the html dom element btnMnsClickEvent(this);, and you need to wrap it with jquery

    2# the second function get object of jquery elements, so there is no problem there

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

Sidebar

Related Questions

I want to show up an ASPxPopupControl whenever an user click a button. But
I was working with UIs where the user will click the add button to
Currently Tomcat's login support redirects users back to where they initially were when the
Initially I thought this was going to work, but now I understand it won't
I initially designed my system following the s# architecture example outlined in this codeproject
In my iPhone app I want to have a UIPickerView with 2 components. Initially
I want to know if its possible writing some code which will delete an
I want to build a vertical menu bar like http://users.tpg.com.au/j_birch/plugins/superfish/#examples But on the mouse
Possible Duplicate: change image on click of button in objective c i draged 3
Initially I deployed packages on SQL server but since my machine is not having

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.