커서가 변경되었는지 감지 할 필요가 없습니다.
마우스가 구조의이 종류를 사용하여 텍스트를 유혹하는 경우 당신은 간단하게 검색 할 수 있습니다 : 당신이 ID를하지만, 클래스 또는 태그가없는 경우
document.getElementById('myTextId').onmouseover = function() {
// do something like for example change the class of a div to change its color :
document.getElementById('myDivId').className = 'otherColor';
};
, 당신은 getElementsByClassName에 의해에서 getElementById를 대체 할 수 또는 getElementByTagName (반복 할 배열을 반환합니다).
요소를 떠날 때 색상을 복원하려면 같은 방법으로 onmouseout 이벤트를 바인딩하는 것이 좋습니다. 당신이 어떤 단락에 뭔가를하려는 경우
예를 들어, 당신이 그렇게 할 수 있습니다 : 당신이 이런 것들을 많이 할 계획
var paras = document.getElementByClassName('p');
for (var i=0; i<paras.length; i++) {
paras[i].onmouseover = function() {
// do something like for example change the class of a div to change its color :
document.getElementById('myDivId').className = 'otherColor';
};
}
, 난 당신이 JQuery와 및 튜토리얼을보고 제안 .
유스 케이스를 설명하면 더 나은 답변을 얻을 수있을 것입니다. 문제를 잘못된 방향으로보고있을 수 있습니다. –
mouseover http://api.jquery.com/mouseover/ –
중복 : http://stackoverflow.com/questions/3395293/check-cursor-is-over-element – mgraph