Skip to content
Snippets Groups Projects
annot.js 776 B
Newer Older
  • Learn to ignore specific revisions
  • Tom Wiesing's avatar
    Tom Wiesing committed
    $(function(){
        var annotationAttribute="data-defines"; // the attribute that we use for annotation
    
        // given an element, find the element it defines
        // has to be of the form #id
        var getDefinedElement = function(elem){
            var selector = $(elem).attr(annotationAttribute).substring(1);
            return $(document.getElementById(selector));
        }
    
        // find all elements that have the attribute
        // and add hover(enterHandler, leaveHandler) handlers
        $("*["+annotationAttribute+"]").hover(function(){
            getDefinedElement(this).attr("mathbackground", "red");
            $(this).css("background-color", "orange");
        }, function(){
            getDefinedElement(this).removeAttr("mathbackground");
            $(this).css("background-color", "");
    
        });
    })