0

Can somebody please give a work around (preferred to be cross-browser) for the following jquery code that fails under internet explorer 8:

var selected = $("#SomeDivElementId :hover");

It is just a div with a nested table in html but it throws the exception:

Object does not support this property or method

The code works fine in Chrome and Firefox.

Maybe I should have been more specific. The $("#SomeDivElementId :hover"); call is expected to return a jQuery object of the element in the div that was hovered on since afterwards I do something like like:

if (selected.length > 0) ...

Thanks.

3
  • are you sure you need a space between #SomeDivElementId and :hover? Commented Oct 13, 2011 at 14:24
  • In the documentation of jquery, I can't find ":hover" like a selector string. Commented Oct 13, 2011 at 14:27
  • Yes Spudley, the space is necessary as far as I know. Without it, the code doesn't work under any browser. Commented Oct 13, 2011 at 14:28

1 Answer 1

1

Use the standard hover() function which takes two callback methods :

var selected = false
$("#SomeDivElementId").hover(function(){selected=true},function(){selected=false})
Sign up to request clarification or add additional context in comments.

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.