0

I am working on creating my first jQuery based plugin but I am stuck at an issue.

I receive an error stating var minHeight is undefined when I am trying to console.log it.

(function ($) {
    $.fn.ezToggle = function (options) {
        var defaults = {
            selector: $('.selector'),
            minHeight: defaults.selector.height(),
            speed: 200
        }
        console.log(defaults.minHeight); // appears undefined       
    };
})(jQuery);

2 Answers 2

1

Use the selector in attribute minHeight too:

minHeight: $('.selector').height();
Sign up to request clarification or add additional context in comments.

Comments

0

You need to make sure to check that selector is defined.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.