title: How can I remove child from Firebase database using a delele button?
body: <p>By using  the following code I read the all child value from firebase database and display all value in a div and every div have a delete button But if want to delete a particular child by click delete button(using loaddelete function) it delete the 1st child of the database . Please can someone tell me how can I remove a particular child by using delete button? Thanks in advance
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>   &lt;script&gt;//from db
          var Ref = firebase.database().ref('Driver');
  
          Ref.on("child_added", function(snap) {
          document.querySelector('.main-content').innerHTML += contactHtmlFromObject(snap.val());
          });
  
  function contactHtmlFromObject(Driver){
    console.log(Driver);
    var html = '';
      html +='&lt;div class="col-md-4"&gt;';
      html +='    &lt;div class="bg-primary img_details"&gt;';
      html +='            &lt;div class="row"&gt;';
      html +='                &lt;div class="col-md-4 col-sm-4 col-xs-4                              img-wrapper" style="height:200px;"&gt;';
      html +='                    &lt;div class="only-img"&gt;';
      html +='                    &lt;img src="'+Driver.FilePhoto+'"                                 height="100%" width="100%"&gt;';
      html +='                    &lt;/div&gt;';
      html +='                    &lt;div class="only-option"&gt;';
      html +='                         &lt;div class="row"&gt;';
      html +='                            &lt;div class="col-md-12"&gt;';
      html +='                                &lt;input                                                      type="checkbox"&gt; Disabled';
      html +='                            &lt;/div&gt;';
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="row"&gt;';
      html +='                            &lt;div class="col-md-4 col-                                 sm-4 col-xs-4"&gt;';
      html +='                                &lt;div type="button"                                              class="btn btn-primary                              edit" onclick="loadedit()"                                      &gt;Edit&lt;/div&gt;';
      html +='                            &lt;/div&gt;';
      html +='                            &lt;div class="col-md-6 col-                         sm-6 col-xs-6"&gt;';
      html +='                                &lt;div type="button"                            class="btn btn-primary delete"                                    onclick="loaddelete()" &gt;Delete&lt;/div&gt;';
      html +='                          &lt;/div&gt;';
      html +='                         &lt;/div&gt;';
      html +='                    &lt;/div&gt;';
      html +='                &lt;/div&gt;';
      html +='                &lt;div class="col-md-8 col-sm-8 col-xs-8                              details-wrapper"&gt;';
      html +='                    &lt;div class="row"&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Name:&lt;/b&gt;                                              '+Driver.Fname+' '+Driver.Lname;
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Address:&lt;/b&gt;                                       '+Driver.Address;
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Experience:&lt;/b&gt;                                          '+Driver.Experience+' Years';
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Phone Number:&lt;/b&gt;                          '+'&lt;span id="phoneid"&gt;'+Driver.Phone+"&lt;/span&gt;";
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Gender:&lt;/b&gt;                                  '+Driver.Gender;
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;Date of Birth:&lt;/b&gt;                                 '+Driver.DOB;
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                            &lt;b&gt;PIN:&lt;/b&gt;                                   '+Driver.Pin+'&lt;/span';
      html +='                        &lt;/div&gt;';
      html +='                        &lt;div class="col-md-12"&gt;';
      html +='                        &lt;b&gt;Hired Date:&lt;/b&gt;                                        '+Driver.HireDate;
      html +='                     &lt;/div&gt;';
      html +='                  &lt;/div&gt;';
      html +='               &lt;/div&gt;';
      html +='            &lt;/div&gt;';
      html +='        &lt;/div&gt;';
      html +='        &lt;/div&gt;';
      return html;
  }
  
  function loaddelete(e) {
      var fdb = firebase.database().ref();
      var phoneid=document.getElementById('phoneid').innerText;
        if(confirm('Are you sure?')){
           alert(fdb.child("Driver/id"+phoneid+'/'));
            
        }
      window.location="driver.html";
  }</code></pre>
  </div>
  </div>
  </p>