Closed tomBeach closed 9 years ago
i would console.log(chipIdString)
to see what the return value of that variable is. Than see if i have a corresponding html element within the $("#columnMiddle")
element after you reassign it on the second line
Hi Tom,
Few things to try:
.find
. That is to say, something like:
$("#" + chipIdString + '_1')
should work just as well. console.log(chipIdString) and make sure it's what you intend, and then manually run
$("#" + chipIdString + '_1')` in the inspector console and see what you get?@tomBeach Closing this out, but feel free to re-open and comment if you still need help.
I am trying to select DOM elements via jQuery with dynamically generated strings that correspond to the id of the target element. It's not working (can't seem to find the element... returns undefined)!
var chipIdString = 'chipsBalp'; chipIdString = chipIdString + nextPlayer.playerIndex + ''; // nextPlayer.playerIndex from playerObject nextChipCount1El = $("#columnMiddle").find("#" + chipIdString + '_1').eq(i + 1);