Setting a button's value using javascript

前端 未结 4 1858
庸人自扰
庸人自扰 2020-11-30 07:46

I\'m sure I\'m going to feel stupid after seeing the answer, but I keep running into prehistoric code around the web, which I\'m not sure still applies. My question is \"How

4条回答
  •  温柔的废话
    2020-11-30 08:28

    there's a much better way to do that. use document.getElementById and give the button an ID.

    function myFunc() {
        document.getElementById('my_button').innerHTML = "New
    Text"; //"other stuff that actually works." return false; }

    I'm not sure you can put a tag into the value of a button, but who knows. Can't say I've tried it.

提交回复
热议问题