D
D
Dmitry Dmitriev2016-02-19 12:22:53
JavaScript
Dmitry Dmitriev, 2016-02-19 12:22:53

How to write the correct JavaScript code for the onClick attribute?

Hello everyone)
The situation is this: I'm trying to make a button with a pop-up window using the Shortcodes Ultimate wordpress plugin.
1. At the first step, I make a pop-up window.
cc9b226af1b84b33891c8e47794d6a08.jpg
2. At the second step, I make a button, when clicked, a popup should appear. When creating a button, you need to fill in the onClick JavaScript code for the onClick attribute . Question: what javascript code to enter there so that a pop-up window appears when clicked?
a1477e3cda89415d8db3c563c26d3fcb.jpg
Thanks in advance for help)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
oleg_drozdov, 2016-02-19
@oleg_drozdov

I don't know the specifics of WordPress, but in regular HTML you have to put a function call there.
For example <button onclick = "openModal();"></button>
A in js:

var a = document.querySelector('.modal')
var openModal = function () {
   a.classList.toogle('open');
}

A
Alexey P, 2016-02-19
@ruddy22

function openModal () {
 // some code
}
document.querySelector('.modal').onClick = openModal;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question