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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:41:34+00:00 2026-06-02T20:41:34+00:00

I have a textbox. On focus I call a javascript function in which I

  • 0

I have a textbox. On focus I call a javascript function in which I create a new element with this way:

var label = document.createElement("label");
label.innerHTML = "*For a more secure password use letters and digits";
document.getElementById('picturediv').appendChild(label);

But onblur I call another function and then I want to remove this element. I’ve tried with the remove but it is not working. I am not sure if the remove is suitable for that.

  • 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-02T20:41:37+00:00Added an answer on June 2, 2026 at 8:41 pm

    You can remove it this way:

    function removeLabel() {
        document.getElementById('picturediv').removeChild(document.getElementById('picturediv').getElementsByTagName('label')[document.getElementById('picturediv').getElementsByTagName('label').length - 1]);
    }
    

    edit:

    The function with comments:

    function removeLabel() {
        var parentNode = document.getElementById('picturediv'); // The parentNode of the label element
    
        var tagsWithLabel = parentNode.getElementsByTagName('label'); // All elements with tag name label
    
        var length = tagsWithLabel.length; // The length of the node array
    
        parentNode.removeChild(tagsWithLabel[length - 1]); // Deleting the last element with tage name label from parentNode.
    }
    

    edit because of comment:

    function removeLabel(id) {
        document.getElementById(id).removeChild(document.getElementById(id).getElementsByTagName('label')[document.getElementById(id).getElementsByTagName('label').length - 1]);
    }
    

    to delete label 1: removeLabel('picturediv'); to delete label 2: removeLabel('picturediv2');

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

Sidebar

Related Questions

I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
$('.my-button').click(function() { $(.my-textbox).focus() }); Before Jquery 1.4 this used to be the way to
I have a requirement to focus on a specific textbox when a new view
I have a textBox and I call an event get focus, when click on
I have a TextBox thats using this Style. I need to add a Focus()
I've a TextBox, on LostFocus event of this i call a function, and here
I have a textbox that when you put focus into it, it drops down
Desktop window application. I have textbox in which user give values in numbers. what
I have a textbox which sends some commands to an instrument. I added the
I have a textbox and a label. If the user wants to change the

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.