Nikhil Agrawal
Nikhil Agrawal

Reputation: 26538

Possible causes of Cannot read property constructor of undefined

I want to iterate over all the forms present in a div. So I am using the following code for this

$('#divid form').each(function (index, formDetails) {
    if (formDetails) {
        console.log($(formDetails).attr('id'));
    }
});

This is working fine in Mozilla with no issues but when I run this code in Chrome sometimes it throws the following error.

This error is coming

Uncaught TypeError: Cannot read property 'Constructor' of undefined

I am using Version 33.0.1750.117 m of Chrome.

Why this error is coming I am not able to understand?

Upvotes: 0

Views: 4154

Answers (1)

Abhishek Saha
Abhishek Saha

Reputation: 2564

Sounds like you don't have jQuery included before your try and load your functions.

Wrap your javascript code inside the below function:

 $(document).ready(function() {

     alert('loaded');
 }

Also check if the initial is $ or jQuery

Upvotes: 1

Related Questions