公告
财富商城
积分规则
提问
发文
2020-02-08 11:08发布
Lonely孤独者°
How do I position a div next to a mouse click using JQuery?
Thanks
You can try:
$( "td").click( function(event) { $("#divId").css( {position:"absolute", top:event.pageY, left: event.pageX}); });
After additional question was asked in the comment:
$( "td").click( function(event) { var div = $("#divId"); div.css( { position:"absolute", top:event.pageY, left: event.pageX}); var delayTimer = setTimeout( function( ) { $that.fadeIn( "slow"); }, 100); div.mouseover( function( event) { if (delayTimer) clearTimeout( delayTimer); }).mouseout( function(){ if (delayTimer) clearTimeout( delayTimer); var $that = $(this); delayTimer = setTimeout( function( ) { $that.fadeOut( "slow"); }, 500) }); });
Something like:
$('#cell').bind('click', function(e){ $('#div').css('left',e.pageX + 'px' ); $('#div').css('top',e.pageY + 'px' ); });
The div's position should be set to absolute.
最多设置5个标签!
You can try:
After additional question was asked in the comment:
Something like:
The div's position should be set to absolute.