سؤال

I was using jQuery's .is() function (the one introduced in 1.6, not the prior version of it) to compare an object, but it unfortunately won't work with jQuery 1.5.2, which is what I am using. I'm wondering if there is some kind of alternative that I can use?

I'm thinking of cloning each object and then comparing it, but this doesn't seem like the best way to do this.

                $('#js-show-more-toggle').contents().each(function() {
                if (seen) {
                    $wrapper.append(this);
                } else if ($(this).is($marker)) {
                    // This is what we want to show
                    seen = true;
                }
            }).end().append($wrapper, $more);

jsfiddle : http://jsfiddle.net/someprimetime/n4jnr/14/

هل كانت مفيدة؟

المحلول

You can use this === $marker[0] to compare the two DOM elements.

Consider upgrading to a recent jQuery version though. Except some minor changes it's usually pretty easy.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top