var token = document.querySelector('input[name="answer_id"][value="630"]') .parentNode.querySelector('input[name="authenticity_token"]').value;