I have an HTML table representing the board in the board game app, it has an arbitrary number of rows and columns in the ' Classes represent elements of playing squares with elements.
I have a small number of 'class = game' board squares, 'class = isatam', at the random places, the Console.log command shows that the initial selector returns an appropriate number of objects and 'rnd' is a valid random The number is but the last console.log fails to detect any 'class = hasAtom' objects - any suggestions please?
Function Place Atom (numberoffium) {var rnd, len; Do it {lenan = $ ('# board. Play: no (.hasAtom)'). Length; Rnd = Math.floor ((Math.random (* * len) + 1); $ ($ (This) .Get (rnd) addClass ('hasAtom'). NumberOfAtoms--;} while (numberOfAtoms> 0 ); Console.log ($ ('# board .play .hasAtom'). Length + 'intersection is atomic')}}
The problem is $ (this) in the selector You must either declare it or pass it in its parameters, assuming that the" #board "element inside the container is a random" .play ", I will try this:
function placeAtoms (numberOfAtoms) {var rnd, len; to do} {lenan = $ ('# board.play: Not (.hasAtom) '). Length; Rnd = Math.floor ((Math.random (* * len) + 1); $ ($ ("run # board"). Eq (rnd). AddClass (' HasAtom ';; numberOfAtoms--;} while (numberOfAtoms> 0); Console.log ($ (' # boards.hasAtom '). Length is +' intersection atom ');}
Comments
Post a Comment