Javascript Jquery调整大小问题。在宽度小于768的情况下,单击“启用选项”。768以上鼠标悬停选项启用 HTML 滑动分页 $(文档).ready(函数(){ listDropdown(); }); $(窗口)。调整大小(函数(){ listDropdown(); }); 函数listDropdown() { var windowWidth=$(window.width(); 如果(窗口宽度>=768) { $(“.profile”)。每个(函数(){ $(this.mouseover(function()){ $(this.find(“.dropdown”).show(); }); $(this.find(“.dropdown”).mouseout(函数(){ $(this.hide(); }); }); $(文档).mouseout(函数(e){ if($(e.target).parents('.profile').length
这里是另一种方法 HTMLJavascript Jquery调整大小问题。在宽度小于768的情况下,单击“启用选项”。768以上鼠标悬停选项启用 HTML 滑动分页 $(文档).ready(函数(){ listDropdown(); }); $(窗口)。调整大小(函数(){ listDropdown(); }); 函数listDropdown() { var windowWidth=$(window.width(); 如果(窗口宽度>=768) { $(“.profile”)。每个(函数(){ $(this.mouseover(function()){ $(this.find(“.dropdown”).show(); }); $(this.find(“.dropdown”).mouseout(函数(){ $(this.hide(); }); }); $(文档).mouseout(函数(e){ if($(e.target).parents('.profile').length,javascript,jquery,html,css,Javascript,Jquery,Html,Css,这里是另一种方法 HTML $(document).ready(function(){ listDropdown(); }); $(window).resize(function(){ listDropdown(); }); function listDropdown() { var windowWidth=$(window).width(); if(windowWidth>=768) { $(".profile").each(fu
$(document).ready(function(){
listDropdown();
});
$(window).resize(function(){
listDropdown();
});
function listDropdown()
{
var windowWidth=$(window).width();
if(windowWidth>=768)
{
$(".profile").each(function(){
$(this).mouseover(function(){
$(this).find(".dropdown").show();
});
$(this).find(".dropdown").mouseout(function(){
$(this).hide();
});
});
$(document).mouseout(function(e) {
if(($(e.target).parents('.profile').length<=0))
{
$(".profile .dropdown").hide();
}
});
}
else if(windowWidth<769)
{
$(".profile").each(function(){
$(this).click(function(){
$(this).find(".dropdown").toggle();
$(this).find(".hoverdropdown").children(".fa-plus").toggleClass("fa-minus");
});
});
}
}
jQuery
.dropdown{
display: none;
}
.hoverdropdown:hover + ul{
display: block;
}
// If you are using jQuery Snippet
@media (max-width:767px){
.open .dropdown{
display: block;
}
}
试试下面的方法
$('.hoverdropdown').click(function(){
$(this).parent().toggleClass('open')
})
函数列表下拉列表()
{
var windowWidth=$(window.width();
如果(窗口宽度>=768)
{
$('.profile').addClass('over');
$('.profile').removeClass('click');
}
else if(WindowWidth)我试过了,但它不能正常工作。当宽度小于768时,鼠标覆盖选项被启用。请修改并帮助我。。。
.dropdown{
display: none;
}
.hoverdropdown:hover + ul{
display: block;
}
// If you are using jQuery Snippet
@media (max-width:767px){
.open .dropdown{
display: block;
}
}
$('.hoverdropdown').click(function(){
$(this).parent().toggleClass('open')
})
function listDropdown()
{
var windowWidth=$(window).width();
if(windowWidth>=768)
{
$('.profile').addClass('over');
$('.profile').removeClass('click');
}
else if(windowWidth<769)
{
$('.profile').removeClass('over');
$('.profile').addClass('click');
}
}
$("body").on('mouseover','.profile.over',function(){
$(this).find(".dropdown").show();
});
$(".dropdown").mouseout(function(){
if($(this).closest('.profile').is('.over')) {
$(this).hide();
}
$(document).mouseout(function(e) {
if(($(e.target).parents('.profile.over').length<=0))
{
$(".profile.over .dropdown").hide();
}
});
$("body").on('click','.profile.click',function(){
$(this).find(".dropdown").toggle();
$(this).find(".hoverdropdown").children(".fa-plus").toggleClass("fa-minus");
});