Reputation: 5
I am having a problem with extracting text after a form is successfully submitted. I want to extract the boxed text and add it to a dom element
I am using Chorme Console for checking. As shown below, this is the max i can traverse. Could you please help me reach the boxed text as shown in the diagram?
document.querySelector("body > div.body > div > section > div > div > div.col-md-12.main-content > div.alert.alert-success.fade.in > a")
Upvotes: 0
Views: 1492
Reputation: 36565
Select the parent element:
el = document.querySelector("body > div.body > div > section > div > div > div.col-md-12.main-content > div.alert.alert-success.fade.in");
Then extract the text only by
thetext = el.innerText;
and removing the 'x' (a more sophisticated solution would find the text of the a element, not relying on it being 'x', and removing that from the string). Of course you are relying on knowing that there isn't additional text in there at some point as you don't have control over the HTML you are traversing, so if some other text was inserted you would get that too - but that's unavoidable.
Upvotes: 1