JQuery get the title of a button

前端 未结 8 1175
遇见更好的自我
遇见更好的自我 2020-12-30 18:33

I have a button:


Which makes this:

8条回答
  •  春和景丽
    2020-12-30 19:14

    You can do this with Vanilla JS, after you've added an ID so you can fetch the element.

    Assuming:

    
    

    You can do in JavaScript:

    var someVar = document.getElementById('myButton').innerHTML; // -> White
    var anotherVar = document.getElementById('myButton').textContent; // -> White
    

    Both will hold "White"

提交回复
热议问题