javascript - How to check and see if a child node in Firebase has data in it -
my plan check see if child node called '1' has data in it. , if does, when user types name , presses 'submit', create new node called '2' them.
$(document).on('click', '#enter', getname); function getname() { var name = $('#user').val().trim(); if(database.ref('players').child(1).exists()) { database.ref('players').child(2).update({ name: name, choice: '', losses: '', wins: '' }); } database.ref('players').child(1).update({ name: name, choice: '', losses: '', wins: '' }); }
Comments
Post a Comment