Jump to content

How to change style inline tag <a>


Eros eros

Recommended Posts

hi guys, I have a tag <a> included in a third-party DIV with the inline style (example style="animation:none!important;background-color:rgba(238,238,238,0.9,........) how can I change it after loading the page? 

I would like to apply display: none or visibility: hidden

Is it possible with CSS?

Edited by Eros eros (see edit history)
Link to comment
Share on other sites

  • Eros eros changed the title to How to change style inline tag <a>

Hello,

Yes, as long as the <a> element is not loaded within an iframe, you should be able to hide it using CSS.

With CSS, you do not need to target that element after the page loads. If the CSS specific code is added, the element will be hidden, even if it's added at a later time.

You might need to use the '!important' property though.

Example:

.div-class a {
    display: none !important;
}

 

Edited by Andrei H (see edit history)
Link to comment
Share on other sites

Hello,

Once you added your styles in the CSS stylesheet, have you also checked the styles that the element has? You can achieve that by right clicking on the element then selecting 'Inspect'

At this point, there are 2 possibilities:
1. Your style was added, but the element overridden it (if this is the case, you should see your style in the Styles tab, but that style being with a strikethrough).
2. Your selector did not match that element, thus the style was never added to the <a> element.

For the first case, the only explanation would be the fact that the element has display !important added to it too. If this is the case, it won't be possible to change that via CSS. At this point, your best shot is doing it via JavaScript - this might be helpful: https://stackoverflow.com/questions/462537/overriding-important-style

Link to comment
Share on other sites

Hello,

Actually, one more thing you can try is the following:

If the element has no position and z-index, you can try to give it a position absolute and a negative z-index, this way having it under the other elements.

Otherwise, you will have to look into the JavaScript stuff.

Link to comment
Share on other sites

Hello,

If you have access to the template where the script tag is loaded, you could try with the onload event - I am not sure if will work, but it's work a try.

Otherwise, one other option might be the setInterval function (https://developer.mozilla.org/en-US/docs/Web/API/setInterval). You call your function multiple times, until you find the a element, then hide it and clear the interval.

Edited by Andrei H (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...