I have a div with 3 different buttons labeled 1 - 3. Currently, all 3 buttons use an inline event that passes its innerHTML as a parameter:
<div class="theClass">
<button onclick="doThing(this.innerHTML)">1</button>
<button onclick="doThing(this.innerHTML)">2</button>
<button onclick="doThing(this.innerHTML)">3</button>
</div>
<script>
function doThing(num){
...
}
</script>
In an effort to both avoid redundancy and avoid inline scripting, I want to know how it would be possible to do this without an inline for each button. How would I make multiple buttons within the same class call the same external script? That is to say, how can I format a function to recognize that a button inside a designated class has been clicked, get the innerHTML of that button, and then pass it as a parameter?