1
<a href=""></a>
<textarea></textarea>
<object></object>
<img src="" />
<div id="content">content</div>
<div class="test">test</div>

And javascript

oj = ['a', '#content', '.test'];
oj.forEach(function(val) {
   val.onmouseover = function() {
      alert("Mouseouver !!!");
   }
});

When I mouseover this object, result not alert, how to fix it ?

1
  • 2
    oj is an array of strings. Not DOM elements. Commented Mar 13, 2013 at 7:16

2 Answers 2

1

If you're about to use jQuery:

$(document).ready(function(){
    $('a, #content, .test').on("mouseover", function(){
        alert("Mouseouver !!!");
    });
});

http://jsfiddle.net/jcWLn/

Sign up to request clarification or add additional context in comments.

Comments

0

You are not adressing the dom objects which is the first problem. The array content points to css classes. You have to fetch individual objects and attach onMouseOver function to them. Have a look at document.getElementById() function...

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.