R
R
Roman2015-09-28 22:41:39
JavaScript
Roman, 2015-09-28 22:41:39

How to use the onclick event?

There is a block: It is necessary that by clicking on this .z1 block, a click on the block with the .z2 class also fires. How to write onclick correctly? Thanks <div class="z1" onclick="">открыть</div>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Stalker_RED, 2015-09-29
@Stalker_RED

I think you want weird.
The telepath on duty isn't back from vacation yet, but I'll try to guess: jsfiddle.net/3qrakLsz

S
Sergey Goryachev, 2015-09-28
@webirus

The question is not entirely clear: what does it mean "a click on a block with the class z2 worked"?
What should the result of the function be?

D
Dmitry Novikov, 2015-09-28
@dmitriy_novikov

easiest way with jquery:

$('.z1').click(function(){
$('.z2').click();
});

V
Vitaly Inchin ☢, 2015-09-29
@In4in

document.querySelector(".z1").onclick = function(){
  document.querySelector(".z2").click();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question