Change a value of existing class with JavaScript? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Is it possible to change the value of a property of an existing CSS class using vanilla JavaScript?
To elaborate, I have a button item in a form, that is styled purely with CSS file. Is there a way to modify the class that applies the style to the item using vanilla JavaScript?
Or should I create a separate class and replace the currently applied class? I think this second option would be the cleanest way, but I was wonder if the first way is actually possible.

You can use inline style attribute
Example document.getElementById('someElement').style.color ='red'

As far as I understand your question you want to make a change in a CSS class itself not to change CSS properties of an element.
It is not possible to do so.
You can either change an element class or component styling via an element.style property

Related

How to make accordion on clear css without bootstrap and html? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 25 days ago.
Improve this question
I can't build accordion on clear css
I have tried a lot of things, but I still can't do it
You can't.
In fact you cant make pretty much anything without HTML (As for Bootstrap is 'just' a wrapper for HTML, CSS and JS.). HTML says where what element is, aka. places the content. CSS defines how it looks and behaves (for the later, you also may need JavaScript).
An accordion in fact needs all three (See this question/answer.)

Fancybox customize specified thumb [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I using fancyBox v3.5.6.
I need to add a CSS class/id/style-attribute to a specific thumb element. I can't do this with changing template, because it will change all thumbs and there is no logic with count of thumbs, and then i can't use css pseudoselectors like last-child or nth-child. I didn't find solution in fancy docs and googling.
Here is an example https://prnt.sc/qqmwbz
Inspect thumbnail elements, each of them has has data-index attribute (for example, data-index="1"), you can use that to do some customization.

Javascript - lock css rule [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is there any concrete way to lock a css rule on an element to be sure it cannot be altered or changed from the browser?
I put a webkit filter on an element abd i would like this to be not altered or removed but afaik is not possible...?!
Or any way to trigger js to get element css rule to stay also if edited from a person by browser !?
You can use the !important CSS rule to make sure none of your other CSS rules override something, for example:
p {
color: red !important;
}
This would ensure all p tags get colored red, and that nothing with a higher priority changes the color to something else.
There is no way to prevent a user from altering HTML, CSS or Javascript from their browser.

Button VS a-tag [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In our application we use A-tags to create all custom styles elements, such as custom CSS buttons.
We alter the A-tags with our CSS and set href='javascript:void(0)'.
The main problem is with Chrome showing the bottom label 'javascript:void(0)' on hover.
Can we just switch all A-tags to button, or is there some major drawback we have consider?
Thanks...
You shouldn't be using an anchor tag in the first place if your anchor tag doesn't point to a URL and is being used as a button. That's sort of like wrapping your text in <b> tags and making it italic.
Making your HTML semantically correct is a good practice, so no, there are no downsides aside from dealing with browsers' default styles for the <button> element.

Is it possible to make elements ignore the re-size of an element not using position:absolute? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would like to know if there is a reasonably efficient way to make elements in a <div> ignore an element being re-sized next to them (by not moving with it) and the element is not position:absolute. I thank anybody in advanced who is willing to help me!
If you have properties you want the element to override you can try !important after the property. It will make properties take precedence over parent elements, and many times you'll get the desired effect. This is good if you need to apply a change quickly, but is not ideal. Ideally, you'll have the parent set up to let the children flow from it.

Categories

Resources