Hi @skenazi, doing this would be possible, but it’s usually a bad idea to mix up PHP, HTML and JS like that – it can get messy real quickly (like, instantly). Instead, you could store those values as data-* attributes to keep your JS logic separate:
You can then access these values in your JS (be sure to include that script at the end of the body so that the DOM is ready when it runs):
// Get a NodeList of all replay-buttons
var replayButtons = document.querySelectorAll('.replay')
// Convert that NodeList to an Array for IE compatibility
// (Yes it's a bit awkward -- we have to "borrow" the .slice()
// method from the Array prototype to this.)
var replayButtonArray = Array.prototype.slice.call(replayButtons)
// Iterate over those buttons
replayButtonArray.forEach(function (button) {
// Attach a click listener
button.addEventListener('click', function (event) {
// Get the values from the data-* attributes
// of the current button
var t1 = this.dataset.t1
var s1 = this.dataset.s1
// ... do something with t1 and s1
console.log(t1, s1)
})
})