Streaming live at 10am (PST)

Copy paste elements without losing it's attributes

Ok, trying to create a series of Modals.

I successfully, and painfully created 3 from scratch.

Now I want 3 more just like them with different images and text etc. So I thought in my head “Ok, easy, I’ll copy/paste the original Modals I created, give the new ones a different class name, then go in and change the image text etc. Easy peasy”.

Not so easy peasy. Here’s what I did:

copied Modal with class “modal” and pasted it where I wanted it. I selected the new Modal and clicked the paintbrush. Then I clicked on the plus to add a class name and named it “modal-3” (the previous 3 modals were named modal, modal-1 and modal-2). Then I clicked the X to remove the old class “modal”.

But then it showed me what you see when you haven’t added a class to an element yet. But I just did…I added “modal-3”. All attributes that WERE there when it carried the “modal” class are now gone.

I tried all this again, but I left both classes, and the modal’s didn’t work properly.

Do I really have to re-build each and every modal one by one from scratch? That’s no easy task. Why can’t I copy/paste an element and just change it’s class without losing it’s attributes?

Hi @James_Welbes, a share link to your project will help us out with your problem.

From the sounds of it you should be able to add another class with the old class and change the properties you want. You said when you tried it that way the elements weren’t working right. I would need to see it to know why it didn’t work because it should have worked.

The class holds the attributes you apply so if you remove the class you remove the attribute.

No, you need to create the element “modal”, complete. then duplicate it twice then add you classes modal1 modal2 modal3 on top of the modal class., Of course you don’t delete the modal class.

That for when you plan in advance

In real life, you sometimes (not me, others) end up with things like “button blue green onblack” because you didn’t plan ahead enough and don’t want to lose you work (ok I do it too).

1 Like