javascript - Dynamically changing cursor/setting cur files -


how can dynamically change style of cursors on div using js or css? because have multiple situations... i've tried code below:

    div.addeventlistener("mouseover", function(evt) {         if (tool == "bc"){           div.style.cursor = "url(/icons/bc.cur)";         }         if (tool == "pan"){           div.style.cursor = "url(/icons/pan.cur)";         }      } 

assuming you're using conditional comments in html5 boilerplate define style (note different syntax newer browser — see mdn docs further information):

div.bc { cursor : url(/icons/bc.cur), auto;  } div.pan { cursor : url(/icons/pan.cur), auto; }  /* style ie<9 */ .lt-ie9 div.bc { cursor : url(/icons/bc.cur); } .lt-ie9 div.pan { cursor : url(/icons/pan.cur); } 

and, assuming simplicity div hasn't class applied, change js code so:

div.addeventlistener("mouseover", function(evt) {     this.classname = tool.tolowercase(); } 

this approach ensure scalability, since in case have cursor list, javascript doesn't need modified further, add new couple of css rules. furthermore totally keep off css javascript, javascript has better mantainability.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -