jQuery : selector targetting a dynamic attribute not working
问题 I'm trying to create a Fanorona game. http://canapin.com/web/fanorona One of my jQuery selector doesn't work as intended. After moving a blue stone by clicking it then clicking on a green space, the active player (var activePlayer) changes from "blue" to "red". $("#board").on("click", "[data-color='"+activePlayer+"']", function(){ console.log(activePlayer); console.log($(this).attr("data-color")); When the active played is "red" and I click on a red stone (data-color="red"), it does nothing.