>  기사  >  웹 프론트엔드  >  jquery jquery.toolTip_jquery를 기반으로 한 사용자 정의 마우스 팁 효과

jquery jquery.toolTip_jquery를 기반으로 한 사용자 정의 마우스 팁 효과

WBOY
WBOY원래의
2016-05-16 18:16:30809검색

IE에서의 효과

Firefox 또는 기타 브라우저 효과


코드

코드 복사 코드는 다음과 같습니다.

// 저작권 Kuche China www.kuchechina.com
//저자 zhuyue.cnblogs.com
//Demo http://www.kuchechina.com/carstools/Default.aspx
jQuery.fn. toolTip = function() {
this.unbind().hover(
function(e) {
this.t = this.title;
this.title = '';
$ ('body').append( '' );
vartip = $('p#p_toolTip').css({ "position": "absolute", "padding ": "10px 5px 5px 10px", "왼쪽": "5px", "글꼴 크기": "14px", "배경색": "흰색", "테두리": "1px 단색 #a6c9e2","line -height":"160%", "-moz-border-radius": "5px", "-webkit-border-radius": "5px", "z-index": "9999"});
var target = $(this);
var position = target.position();
this.top = (position.top - 8) this.left = (position.left target.width() 5) ;
$('p#p_toolTip #img_toolTip_Arrow').css({"position": "absolute", "top": "8px", "left": "-6px" })
팁. css({"top": this.top "px","left":this.left "px"})
tip.fadeIn("slow")
},
function() {
this.title = this.t;
$("p#p_toolTip").fadeOut("slow").remove()
}
}; 🎜>

사용법:


< ;script type="text/javascript">
$(document).ready(function(){
$("#tootlsMain img[title]").toolTip();
} );



jquery 선택기를 사용하여 제목 속성이 있는 태그를 선택할 수 있습니다. 물론, alt 속성이 있는 태그를 적용하도록 코드를 적절하게 수정할 수도 있습니다.
제목 속성은 간단한 HTML 태그를 지원합니다.
따옴표 사용에 주의하세요
구현 원칙:
라벨 제목 속성을 사용하여 호버 이벤트가 기본 마우스 이벤트를 대체하고 플로팅 레이어를 표시하도록 합니다. this.unbind().hover가 이 코드입니다. jquery는 우리가 많은 일을 할 수 있도록 도와줍니다. 실제 코드를 쌓아보세요.
프로그래머님, 글쓰기 스타일을 이해해 주시길 바랍니다.


코드 다운로드
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.