Following javascript code throws error
Uncaught TypeError: Object #<HTMLSpanElement> has no method 'getElementById'
If this is not allowed how do I search for the existence of particular element inside other element?
var googlePlusPosts = document.getElementsByClassName("mo fj");
for (var i = 0; i < googlePlusPosts .length; ++i) {
decryptElements = googlePlusPosts[i].getElementById('decrypt-button');
.
.
.
IDs must be unique; thus it doesn’t really make sense to look inside a particular node for a particular ID; either the ID exists, or it doesn’t.
You can use element.getElementsByClassName to get child elements of a particular class, or element.getElementsByTagName to get them by their tag name.
EDIT: Ignore the below; just saved for posterity.
Check if the element has the getElementById method ahead of time.