Javascript jQuery-将鼠标悬停在一个元素上以更改两个不同的元素

Javascript jQuery-将鼠标悬停在一个元素上以更改两个不同的元素,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个网站,其特点是图像网格,右边有一个简单的文本框。盒子内有一个h3和p元件。当鼠标悬停在特定的图像上时,我希望h3和p发生变化。目前h3的变化没有问题,但是p文本只有在鼠标离开所述图像时才会变化 网站: 将鼠标悬停在第一个图像上,例如左上角。h3将变为完全闭上眼睛,但p文本仅在鼠标移出时更改。当您将鼠标悬停在标题上时,也会发生同样的情况。我怎样才能让它们同时改变呢 相关HTML: <div id="grid"> <div class="grid-element"

我有一个网站,其特点是图像网格,右边有一个简单的文本框。盒子内有一个h3和p元件。当鼠标悬停在特定的图像上时,我希望h3和p发生变化。目前h3的变化没有问题,但是p文本只有在鼠标离开所述图像时才会变化

网站:

将鼠标悬停在第一个图像上,例如左上角。h3将变为完全闭上眼睛,但p文本仅在鼠标移出时更改。当您将鼠标悬停在标题上时,也会发生同样的情况。我怎样才能让它们同时改变呢

相关HTML:

<div id="grid">

    <div class="grid-element" id="ews">
        <a href="#"><img src="img/ews.jpg"/></a>
        <span></span>
    </div>

我是如何使用jQuery的:

$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
} , function() { 
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});

为什么不把它们放在一起呢

$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});

就这样做吧。我在
控制台中尝试了以下操作:

$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});

谢谢这就解决了问题。我想它必须分开。
$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
} , function() { 
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});
$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});
$('.grid-element#ews').hover( function() { 
   $('.right-content h3').text("EYES WIDE SHUT");
   $('.right-content p').text("After Dr. Bill Hartford's wife, Alice, admits to having sexual fantasies about a man she met, Bill becomes obsessed with having a sexual encounter. He discovers an underground sexual group and attends one of their meetings -- and quickly discovers that he is in over his head.");
});