1 Replies - 6596 Views - Last Post: 18 January 2013 - 05:06 PM

#1 dan_joita  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 12-January 13

using a value from where the mouse pointer is

Posted 13 January 2013 - 01:04 AM

hi,

i have more rows with different users and i want to get the user id from where the mouse pointer is and land it in the image source of mini_profile div
this stupid code of mine looks like this
php file
echo "<span class='hover'>".$row1['name']."<span class='id_user' style='transparency:1%;'>".$row1['id_user']."</span></span>";
echo "<span class='hover'>".$row2['name']."<span class='id_user' style='transparency:1%;'>".$row2['id_user']."</span></span>";
<div id="mini_profile" style="display:none;position:absolute"><img src="/img/u<?php echo $row 1 or 2 depending where the mouse cursor is ['id_user'] ?>.png" ></div>

js file
$(function(){
	$(document).mousemove( function(e) {
		mouseX = e.pageX; 
		mouseY = e.pageY;
	});
	$(".hover").hover(function(){
		//$("#mini_profile").text($(this).text());
		$("#mini_profile").css({'top':mouseY,'left':mouseX}).show();
	},
	function(){
		$("#mini_profile").fadeOut(500);
	});
});


so any ideas how to make this more logical, because i think it is very twisted

thank you,
Dan.

Is This A Good Question/Topic? 0
  • +

Replies To: using a value from where the mouse pointer is

#2 exiles.prx  Icon User is offline

  • D.I.C Head

Reputation: 65
  • View blog
  • Posts: 239
  • Joined: 22-November 10

Re: using a value from where the mouse pointer is

Posted 18 January 2013 - 05:06 PM

Maybe something like this:

$(function(){
    $('.hover').live({mouseenter: function(e) {
        $("#mini_profile").css({'top':e.pageY,'left':e.pageX}).show();
    }, mouseleave: function() {
        $("#mini_profile").fadeOut(500);
    }});
});

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1