How to add a class to a given element

0 votes

I already have a class for an element:

<div class="someclass">
    <img ... id="image1" name="image1" />
</div>

I'd want to write a JavaScript function that adds a class to the div (not replace, but add).

How can I accomplish this?

Sep 28 in Java by Nicholas
• 7,120 points
34 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
2 answers

How can we add an image to a JPanel?

If you are using JPanels, then are ...READ MORE

answered Sep 20, 2018 in Java by Daisy
• 8,120 points
9,858 views
0 votes
1 answer

How to count the number of occurrences of an element in a List?

We can use the static frequency() method. int ...READ MORE

answered Aug 21, 2018 in Java by sharth
• 3,350 points
4,848 views
0 votes
1 answer

How to add items in list at a time?

Hi Priyanka , I think this code snippet ...READ MORE

answered Aug 9, 2019 in Java by sampriti
• 1,120 points
1,859 views
0 votes
2 answers

How to generate a class at runtime?

Yes, I recently met this library which ...READ MORE

answered Apr 15, 2020 in Java by Edureka
• 520 points
8,970 views
0 votes
1 answer

How to add local jar files to a Maven project?

Hello @kartik, You can add local dependencies directly ...READ MORE

answered Jul 28, 2020 in Java by Niroj
• 82,800 points
1,415 views
0 votes
0 answers

How to set XML Attribute inside XML Element in Java Pojo Class - JAVX

How can I get this Output Response? <Response> ...READ MORE

Apr 19 in Java by Rahul
• 3,380 points
595 views
0 votes
0 answers

How to add a class to a given element?

I am trying to create a JavaScript ...READ MORE

May 16 in Java-Script by Kichu
• 19,040 points
42 views
0 votes
1 answer

Presenting docket dtates inside html page by javascript

Use the Docker Engine Api:Docker Engine API ...READ MORE

answered Jun 20, 2018 in Docker by DareDev
• 6,890 points
256 views
0 votes
1 answer

Migrating proxy npm repo in nexus 3

I don't think you can achieve this ...READ MORE

answered Jun 22, 2018 in DevOps Tools by DareDev
• 6,890 points
883 views
+1 vote
1 answer

What is the difference between JavaScript and Java

This quote rightly explains that 2 totally ...READ MORE

answered Jun 29, 2018 in Java by Daisy
• 8,120 points
280 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP