我对jquery有一些问题。
我有运行正常的代码,但我想在这两个函数上添加一些延迟(淡入等)。
$(document).ready(function(){
$(".product-item, .rade-test").mouseover(function(){
$('.just-to-define').removeClass('rade-test-div');
$('.just-to-define').addClass('rade-test-div2');
$('.heredefine').removeClass('rade-test');
$('.heredefine').addClass('rade-test2');
});
$( ".product-item, .rade-test" ).mouseout(function() {
$('.just-to-define').addClass('rade-test-div');
$('.just-to-define').removeClass('rade-test-div2');
$('.heredefine').addClass('rade-test');
$('.heredefine').removeClass('rade-test2');
});
});
我试过了
$(".product-item, .rade-test").mouseover(function(){
$('.just-to-define').removeClass('rade-test-div');
$('.just-to-define').addClass('rade-test-div2');
$('.heredefine').removeClass('rade-test');
$('.heredefine').addClass('rade-test2');
}, 2000);
但出于某种原因,这行不通。我不知道为什么。所以在这里,当它必须添加类时,我需要淡入/延迟/“处理时间”,并且我已经尝试了
.fadeIn("slow")
第二个问题是,我的模板中有一个表,当鼠标悬停在表上时(见jquery函数),它将打开我编写的每个类(rade-test-div2和rade-test2),当我添加.first()时,它只是第一个ofc。我怎样才能只打开我的鼠标在哪里?
product item类在表的tr元素中,因此我可以添加如下内容
@php $uniqueId = uniqId(); @endphp
<tr class="product-item {{$uniqueId}}">
但是如何在jquery中写入来选择这个$uniqueid?我的jquery代码在另一个文件中。