I would like to select an element based on a substring of href attribute.
I posted a question recently where I received an answer based on "starts with":
document.querySelector('#utility-menu a[href^="/email_check?lang="').textContent.trim();
But actually, the only constant from page to page will be "lang="
within the href attribute. So /email_check?
is page specific so I cannot use this variable on al pages.
Is it possible to modify my selector to return the textContent of any <a>
element with the substring "lang="
within it?
question from:
https://stackoverflow.com/questions/31773599/can-i-use-an-attribute-selector-for-contains-in-queryselector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…