带有添加和删除类的jQuery-less函数
我试图在宽度设置之前和之后添加和删除类,一旦宽度小于1140,addclass和remove类就可以完美地工作,但当with大于1140时,remove class和add class不起作用。如果我能得到任何帮助的话,我真的会去的带有添加和删除类的jQuery-less函数,jquery,Jquery,我试图在宽度设置之前和之后添加和删除类,一旦宽度小于1140,addclass和remove类就可以完美地工作,但当with大于1140时,remove class和add class不起作用。如果我能得到任何帮助的话,我真的会去的 jQuery(document).ready(function($){ var low = false; $(document).ready(function() { var pageWidth = $(window).width();
jQuery(document).ready(function($){
var low = false;
$(document).ready(function() {
var pageWidth = $(window).width();
if (pageWidth <= 1140) {
low = true;
$('.studio .thirtyheight').removeClass('thirtyheight').addClass('workfullheight');
$('.studio .sixtyheight').removeClass('sixtyheight').addClass('workfullheighttwo');
}
$(window).resize(function() {
if ($(window).width() <= 1140) {
if (!low) {
low = true;
$('.studio .thirtyheight').removeClass('thirtyheight').addClass('workfullheight');
$('.studio .sixtyheight').removeClass('sixtyheight').addClass('workfullheighttwo');
}
}
else if (low) {
low = false;
$('.studio .workfullheight').addClass('thirtyheight').removeClass('workfullheight');
$('.studio .workfullheighttwo').addClass('sixtyheight').removeClass('workfullheighttwo');
}
});
});
});
jQuery(文档).ready(函数($){
var低=假;
$(文档).ready(函数(){
var pageWidth=$(窗口).width();
如果(pageWidth您忘记了其他情况
使用它,它就会工作
var $window = $(window),
$html = $('.studio .thirtyheight'),
$htmltwo = $('.studio .sixtyheight');
if ($window.width() < 1140) {
return $html.addClass('workfullheight').removeClass('thirtyheight'),
$htmltwo.addClass('workfullheighttwo').removeClass('sixtyheight');
}else{
$html.removeClass('workfullheight').addClass('thirtyheight'),
$htmltwo.removeClass('workfullheighttwo').addClass('sixtyheight');
}
var$window=$(window),
$html=$('.studio.thirtyheight'),
$htmltwo=$('.studio.sixtyheight');
如果($window.width()<1140){
返回$html.addClass('workfullheight')。removeClass('thirtyheight'),
$htmltwo.addClass('workfullheighttwo').removeClass('sixtyheight');
}否则{
$html.removeClass('workfullheight').addClass('thirtyheight'),
$htmltwo.removeClass('workfullheighttwo').addClass('sixtyheight');
}
jQuery(文档).ready(函数($){
var低=假;
$(文档).ready(函数(){
var pageWidth=$(窗口).width();
如果(pageWidth)尝试将其更改为$html.addClass('thirtyheight').removeClass('workfullheight')
。为什么返回它/用分隔它?
?即使使用调整大小代码调整窗口大小时,仍然没有删除已分类的内容?请应用调整大小()当调整大小事件发生时,请调用您的代码itys WORKS。我已经查看了一遍,但仍然无法按计划执行,我已更新了上面的示例。如果您在ordanary中看到任何内容,请告诉我。
jQuery(document).ready(function($){
var low = false;
$(document).ready(function() {
var pageWidth = $(window).width();
if (pageWidth <= 1140) {
low = true;
$('.studio .thirtyheight').removeClass('thirtyheight').addClass('workfullheight');
$('.studio .sixtyheight').removeClass('sixtyheight').addClass('workfullheighttwo');
}
$(window).resize(function() {
if ($(window).width() <= 1140) {
if (!low) {
low = true;
$('.studio .thirtyheight').removeClass('thirtyheight').addClass('workfullheight');
$('.studio .sixtyheight').removeClass('sixtyheight').addClass('workfullheighttwo');
}
}
else if (low) {
low = false;
$('.studio .workfullheight').addClass('thirtyheight').removeClass('workfullheight');
$('.studio .workfullheighttwo').addClass('sixtyheight').removeClass('workfullheighttwo');
}
});
});
});