Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Html input field is inside anchor tag like so ..

<a id="brand" onclick="myFunction()" class="brand" ><input id="mytext" onclick="myFunction()" type="hidden" value="Anchor Title">Anchor Title</a>

Javascript uses set attribute

<script>
function myFunction() {
    document.getElementById("brand").innerHTML = "";

    document.getElementById("mytext").setAttribute("type", "value");

    var elem = document.getElementById("mytext");

    elem.value = "Edit Title";

    document.getElementById("brand").innerHTML = elem.value;
    }
</script>

RESULTS

  • Anchor title is cleared on click
  • But, the input field is still hidden
share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.