Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove an html button using js

Hi I have a bit of code below that creates a button on a html form. When a user has entered some information using the button I want the form to reflect this by removing the button and replacing it with just plain text. I have tried getting the inner html and using divs but nothing is working can anybody help please? I am not looking for anyone to write code for me just a few pointers would be great . thanks

  <td class="col1"><h3>Associated with :</h3></td>
  <td class="col3">
  <input type="button" 
  value="Associate this job " 
  onclick="associate()" 
/></td>
like image 910
Mick Avatar asked Aug 17 '10 21:08

Mick


People also ask

What does remove () do JS?

The JavaScript delete operator removes a property from an object; if no more references to the same property are held, it is eventually released automatically.

Is there a remove method in JavaScript?

Summary. Removing JavaScript Array items is important to managing your data. There is not a single 'remove' method available, but there are different methods and techniques you can use to purge unwanted array items.

What is used to delete an HTML element from DOM?

remove() The Element. remove() method removes the element from the DOM.


Video Answer


1 Answers

Add a span with an idattribute around whatever it is you want to change. When it's time, here's all you need to do:

    document.getElementById("spanIDhere").innerHTML = "Your text here";

So for instance, you'd have the line:

    <span id="associatespan">
        <input type="button" value="Associate this job" onclick="associate()" />
    </span>

and your script would say:

    document.getElementById("associateSpan").innerHTML = "Look, no more button!";
like image 171
Dori Avatar answered Sep 30 '22 17:09

Dori