How to create a button? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How to create a button?

I have a button called "Cars". When I place mouse over it displays dropdown list consisted of items: "BMW", "Mercedes", "VW", "KIA". I want to create a button (or something similar) next to the button Cars, when I click the specific item from a dropdown list. So, when I click BMW, I want it to look like this: Cars > BMW The same is for other items. That button shouldn't be displayed before clicking. Just onclick.

17th Jan 2017, 5:53 PM
Wolfinho
3 Answers
0
It sounds like you're looking for someone to do your work for you... javacsript has an onclick event. Pair this with an InnerHTML write to change your DOM. Or, you can use jQuery .click() method with it's .html() method inside the click function.
17th Jan 2017, 6:07 PM
Louis Milotte
Louis Milotte - avatar
0
i am not familiar with jQuery and dont want to learn it. i know for onclick event but it just doesn't work.. i wouldn't ask if i know how to do it, believe me, i would just write the bloody code.. inner html just change my Cars button to BMW not create a new beside the Cars..
17th Jan 2017, 6:22 PM
Wolfinho
0
write what you have now and link it here. I'll point out fixes when I'm not busy at work.
17th Jan 2017, 6:43 PM
Louis Milotte
Louis Milotte - avatar