check a text is before or after another text
added comments for each step
check a text is before or after another text in an element