My footer elements are loading with dynamic id’s. I used as follows
$(document).ready(function () {
$("[id^='footer']").click(function (evt) {
evt.preventDefault();
if (window && window.siteConsent && window.siteConsent.manageConsent) {
window.siteConsent.manageConsent();
}
console.log(evt.target.id)
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<a href="level2Link.NavLink" class="f-link managecookieShow" id="footer-nav-ManageCookies one1" aria-label="level2Link_AriaLabel">
One
</a>
<br/>
<a href="level2Link.NavLink" class="f-link managecookieShow" id="footer-nav-ManageCookies two2" aria-label="level2Link_AriaLabel">
two
</a>
Actually it is not working. When i am using ^ this symbol is for getting contains of the id name. But it did not helped me.
2
Answers
You can use "Attribute Contains Selector"
[name*="value"]
I think this symbol "^" cannot help you to select the component that its id contains substring.
But you can use "*" symbol to select that component.
For example:
$("a[id*='footer']")