I
I
Ivan2015-10-23 09:41:50
JavaScript
Ivan, 2015-10-23 09:41:50

How to make several buttons on the site, when clicked, certain text will be added to a certain div and hide the previous text?

487df883006a4ea59d0999e4bfc786ad.PNG
There is such an element on the site, I want to make it so that when you click on small circles, text appears in the center of the large one, each has its own text, while the previous text disappears. I know that this can be done with jquery, but I have no idea how to do it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Inchin ☢, 2015-10-23
@In4in

Let's add a data attribute to each circle :
And then some jQuery:

$(document).on("click", selector, function(){
   $(output).text(this.dataset.word);
   //Или $(this).attr("data-word");
});

selector - CSS round block selector.
output - block selector where the text will be output

A
Anton Fedoryan, 2015-10-23
@AnnTHony

I know that this can be done with jquery, but I have no idea how to do it.

Mutually exclusive paragraphs? And how do you know how to use Google?
For example, here is a query that gives a completely logical answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question