I have a button and when I click on it, a window should pop up through fadeIn() jQuery. Everything is very simple, here is the program device.

TYK is made here. And it appears after this (p / n - the result in the widget)

Here we have a script

 document.getElementById('baton').onclick = function() { $('#coders').fadeIn(); } 
 #coders { position: absolute; background-color: red; width: 25%; height: 35%; display: none; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> <div id="baton"> <p style="text-align: center;" class="landing_text">Разработчики</p> </div> 

On fakut should work. Does not work.

    1 answer 1

    The answer is quite simple - you do not have an element with id coders . As a result, fadeIn nothing to apply fadeIn to. The moment number 2 - an empty div. #baton does not have its length and height and therefore is virtually invisible. And therefore you won't be able to trigger a click event until you put at least some height to it (because the child element is hidden; the diva will have zero height) so that you can click on it. Here is my option:

     document.getElementById('block').onclick = function() { $('#label').fadeIn(); } 
     #label { position: absolute; background-color: red; width: 25%; height: 35%; left: -10%; margin-left: 50%; display: none; text-align: center; } #block { background-color: red; width: 100%; height: 40px; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> <div id="block"> <p id="label" class="landing_text">Разработчики</p> </div> 

    • #baton has the same length and height, there are no problems with it, but please specify the first one - newArray
    • there is an element with id #coders too, it also has a length and height present - newArray
    • In your example, the child element is hidden by default (display: none) and therefore the parent unit will be empty and have a zero height - alexoander
    • check your html again (I didn’t fix it specifically) and make sure you don’t have a block with id = coders - alexoander
    • thank you, plus you) - newArray