Jitendra Vyas
Jitendra Vyas

Reputation: 152767

element = $(element); Object expected error?

on a webpage in under developmnt i'm getting this error on IE

element = $(element);   

this code is in prototype.js

Object expected

How to get rid of this error.

Update:

jQuery is also being used on site.

Upvotes: 0

Views: 783

Answers (3)

Minimul
Minimul

Reputation: 4215

You need to put a var in front of the variable assignment when the variable and element id are the same in IE.

var element = $(element);

Upvotes: 1

Adeel
Adeel

Reputation: 19228

your statement should be

element = $("id of element")

suppose you have the following code.

<div id="mainDiv">
  ...
</div>

To access this control, in prototype, it is

element = $("mainDiv");

UPDATE:

Based on your comment, you can combine both jquery and prototype in the same page.

var J = jQuery.noConflict();

After this statement, $("#foo") will be J("#foo").

See this stackoverflow question

Upvotes: 2

Tim Goodman
Tim Goodman

Reputation: 23976

Is "element" the id of your element? If so try making it element = $("element")

Upvotes: 3

Related Questions