Search code examples
javascriptprototypejs

Write a mouseover function using prototypejs


I want to re-write the following jquery code using prototypejs. How can I do that?

<a  class="btn" id="control" href="javascript:control();">Control</a>

$('#control').on({
    mouseover: function() {
        $('#bg2').css({
            background: '#F93'
        });
    },
}); 

Solution

  • $('control').observe('mouseover', function(event) {
      $('bg2').setStyle({
          background: '#F93'
      });
    });
    

    You can find all the information here:

    http://api.prototypejs.org/dom/Event/

    http://api.prototypejs.org/dom/Element/setStyle/