我有以下问题:我的鼠标输入方法不起作用,我不知道为什么。按下的鼠标完美无缺,只有 mouseEntered 不行。
这是鼠标监听器:
MouseListener mouseListener = new MouseListener() {
public void mouseClicked(MouseEvent e) {
jpopup.setLocation(e.getX(), e.getY());
jpopup.setInvoker(jpopup);
jpopup.setVisible(true);
System.out.println("Tray Icon - Mouse clicked!");
}
@Override
public void mouseEntered(MouseEvent e) {
System.out.println("Tray Icon - Mouse entered!");
}
public void mouseExited(MouseEvent e) {
System.out.println("Tray Icon - Mouse exited!");
}
public void mousePressed(MouseEvent e) {
System.out.println("Tray Icon - Mouse pressed!");
}
public void mouseReleased(MouseEvent e) {
System.out.println("Tray Icon - Mouse released!");
}
};
Run Code Online (Sandbox Code Playgroud)
这里是托盘图标:
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);
Run Code Online (Sandbox Code Playgroud)
错误在哪里?我不知道...
编辑:我正在使用日食,如果这很有趣......
我有一个div包含多个具有绝对位置的div,我想处理父div的鼠标输入事件我使用这个小提琴: 小提琴 它没有正常工作是他们的任何其他方式来处理这个问题?
HTML标记
<div id="content">
SYDNEY (Reuters) - An Australian man had his driving licence suspended for 10 months and was fined after he was
<div class="abs"></div>
caught driving a scooter made of a motorised beer cooler capable of carrying several dozen drinks -- after knocking back a few.
</div>
<div id="output">
</div>
Run Code Online (Sandbox Code Playgroud)
脚本
$(function() {
var output = $("#output");
$("#content")
.mouseenter(function(e){
output.text("I'm in!");
}).mouseout(function(e) {
output.text("I'm out!");
});
});?
#content {
background-color:#cccc99;
position:relative;
}
.abs{
position:absolute;
top:0px;
left:70px; …Run Code Online (Sandbox Code Playgroud) 是否存在某种jQuery淡入黑色效果与图片的特定部分.所以它真的把图片变成黑色吗?我知道canvas元素,但它对我来说似乎不是一个很好的解决方案,会感激一些帮助:)
我有一张照片和一张div.div是隐藏的(display:none;).我想在鼠标悬停在图片上时显示div,并在鼠标未在图片上方时再次隐藏div.我使用mouseenter()和mouseleave()事件来执行此操作,但当moue在图片上时,两个函数都重复工作.这是我定义函数的代码:`
$("#pic").mouseenter(function(){
$("#checkin").slideDown();
});
$("#pic").mouseleave(function(){
$("#checkin").slideUp();
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了悬停方法但结果是一样的.
$("#pic").hover(
function(){
$("#checkin").slideDown(200);
},
function(){
$("#checkin").slideUp(200);
}
);
Run Code Online (Sandbox Code Playgroud)
有什么问题,我无法理解.
更新: 这是HTML代码
<tr><td valign='top' class='checkinpic'><img src='img.png' id='pic' height='100%'></td></tr>
Run Code Online (Sandbox Code Playgroud)
...
<div id='checkin'>
You are not going to any activity this week.
</div>
Run Code Online (Sandbox Code Playgroud) 大家好,所以我要做的是使用jquery动画按钮背景颜色.
$(document).ready(function(){
$('button').mouseenter(function(){
$('button').animate({
background-color:"blue"},1000);
});
$('button').mouseleave(function() {
$('button').animate({
background-color:"white"},1000);
});
});
Run Code Online (Sandbox Code Playgroud)
我做错了什么?还有一件事,你能解释一下傻瓜吗?:d
PS:我正在使用bootstrap
在我的代码中,我有一个id为'SIAinfoBox'的div,它将加载不同的细节,具体取决于鼠标当前所处的div.我将以下两个监听器附加到每个相关的div:
$(annoDiv).mouseover(function(event){
event.stopPropagation;
$('#SIAinfoBox').empty();
$('#SIAinfoBox').append(details);
$('#SIAinfoBox').css('visibility','visible');
});
$(annoDiv).mouseleave(function(event){
event.stopPropagation;
$('#SIAinfoBox').empty();
$('#SIAinfoBox').css('visibility','hidden');
});
Run Code Online (Sandbox Code Playgroud)
这些div没有背景颜色设置,但有1px纯黑色边框.在Firefox中,一切运行良好.但是在Internet Explorer中,仅当鼠标位于div的边界上时才会填充SIAinfoBox.在div中移动它似乎会触发mouseleave事件,并删除内容并隐藏div.如果我设置背景颜色,它的工作方式与预期的一样,但没有背景颜色(或透明),它不起作用.我也尝试使用mouseenter而不是mouseover,但结果相同.为什么InternetExplorer表现得像那样,或者我该怎么做才能实现我目前在FF for IE中获得的结果呢?
我myNestContainer在文档准备好了隐藏控制面板().我有一个按钮navMyNest,当mouseenter发生时,显示myNestContainer.这很好用.
问题是我希望用户能够探索控制面板,但是如果输入了嵌套的DIV容器,则myNestContainer只要输入一个,mouseleave生效和控制面板就会关闭.
这比mouseenter/ 更好mouseout,但仍然没有我想要的功能.
有关如何覆盖子对象的任何想法,以便控制面板在用户查看时保持打开状态?
提前致谢.
$(document).ready(function() {
$("div#myNestContainer").hide();
});
$("div#navMyNest").live("mouseenter", function(event) {
$("div#myNestContainer").show();
});
$("div#myNestContainer").live("mouseleave", function(event) {
$("div#myNestContainer").hide();
});
Run Code Online (Sandbox Code Playgroud) 当我有多个具有相同类的div时,我怎么能只在div上执行动作
http://jsfiddle.net/kent93/Qw7bw/
当鼠标输入一个div时,另一个div也会有动作,我该如何解决这个问题
我只想要我的鼠标进行操作的div,而不是其他,什么是最佳解决方案?
我在Firefox 16中遇到了一个奇怪的问题.
在一个div中,我正在淡入一个mouseenter(和淡出mouseleave)事件,有一个嵌入的选择标签.当我将鼠标移到选项上时,div会逐渐消失,等等.但是没有机会选择一个选项.
这不会发生在Chrome中.有谁知道为什么会这样,以及如何解决它?
我一直试图让一个函数只在所有元素的.animate()功能完成后触发,包括延迟和缓和.
我尝试了几种不同的方法,没有运气,任何想法?
$("#inner_work").on("mouseenter", ".activeBox", function(){
var thisBox = $(this).attr('id');
$("#inner_work [class^='workBox_']").each(function(){
if($(this).attr('id') != thisBox){
$(this).stop().delay(randomEasing(200,800)).animate({
opacity:0
}, randomEasing(200,700));
} else {
$(this).stop().animate({
opacity:1
}, 'fast');
}
});
});
Run Code Online (Sandbox Code Playgroud)
所有动画完成后如何触发事件?
randomEasing 只是这个函数让它随机交错
function randomEasing(from,to)
{
return Math.floor(Math.random()*(to-from+1)+from);
}
Run Code Online (Sandbox Code Playgroud) mouseenter ×10
jquery ×9
javascript ×4
mouseleave ×3
css ×2
animation ×1
easing ×1
fadein ×1
firefox ×1
html ×1
java ×1
jquery-hover ×1
mouseover ×1
random ×1
trayicon ×1