There is such jQuery code

$('.error_fixed').children().eq(0).addClass('alert_error').html('Ошика') 

So I gave the child a class of 'alert_error', and how can I now directly contact the parent myself in the same thread?

You can of course

 $('.error_fixed').children().eq(0).addClass('alert_error').html('Ошика').parent().css('background', 'red') 

But this is not an option.

    1 answer 1

    But this is not an option.

    From what? parent does an excellent job.

     $('.error_fixed').children().eq(0).addClass('alert_error').html('Ошика').parent().css('background', 'red') 
     .alert_error{ color: green; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class='error_fixed'> some <div>error</div> </div> 

    UPDATE:

    According to the explanation in the comments, the desired solution was found: end .

    • It works, it works, I just heard somewhere that there is a method that returns to the parent, I just don’t remember .. - Flayter
    • @ user208233, well, parent is what he is. - user207618
    • Something related to .self () or .back () was. Let's just say, not even the parent needs to get access, but the first element of the chain, because I can write $ ('. Error_fixed'). Children (). Eq (0) .addClass ('alert_error'). Html (' Oshika '). Children (). Eq (0) .html (' Text of a child with a parent h4 '). Parent (). Css (' background ',' red '); - it will already be another parent - Flayter
    • @Flayter, then this: end : jquery.page2page.ru/index.php5/… - user207618
    • Exactly, it's the most - Flayter