When I click on the div tag where I have created a function in which I will redirect to a static page, which is working fine, but when I click on the anchor tag which is present in lightning-formatted-rich-text, it will be dynamic then the handleClickDiv function is redirecting first but I need to redirect on that URL which is present in href attribute of the anchor tag.
This is the code of the javascript file which we used in the lightning web component in Salesforce.
richtext = '<h2>Default </h2> </br> <a href="https://developer.salesforce.com" rel="noopener noreferrer" target="_blank">click</a>';
<div onclick={handleClickDiv}>
<lightning-formatted-rich-text value={richtext}></lightning-formatted-rich-text>
</div>
Only I need that stop-on-click functionality when I click on the anchor tag.
I tried to get an anchor tag in the lightning web component(LWC) js file, but I cannot get that.
I tried the below code and this is returning null to me.
var eles = this.template.querySelectorAll('a');