.toggle (true) throw null in $ (document) .ready (function ())

I go over brothers and sisters. I wrote .toggle (true) when the document is ready. see picture below. I think a sibling is not available before this function calls.

alt text

 $(document).ready(function() {

       $('tr[@class^=RegText]').hide().children('td');

        list_Visible_Ids = [];
        var idsString, idsArray;

        idsString = $('#myVisibleRows').val();
        idsArray = idsString.split(',');

        $.each(idsArray, function() {
            if (this != "") {
                $(this).siblings('.RegText').toggle(true);
                list_Visible_Ids[this] = 1;
            }
        });

alt text

alt text

How to solve this? why sliblings are not available when the document is ready?

+3
source share
1 answer

Your published code does not match the debugger code, your code has this, which (almost!) Is correct:

$(this).siblings('.RegText').toggle(true);

The debugger has this, which is wrong:

$(this).siblings(('.RegText').toggle(true));

You need to update everything that you actually debug on this code, without additional brackets, otherwise you will get quite funny behavior there.

#, , , . $("row10") ( <row10>), $("#row10") ( id="row10"), :

$('#' + this).siblings('.RegText').toggle(true);
+4

Source: https://habr.com/ru/post/1744721/


All Articles