0

我知道这可能很容易,但我被困在这里。我想ui-mobile从我的<html>标签中删除

<html class="ui-mobile">

我试过这个

$(html).removeClass('.ui-mobile');

但它会引发以下异常

Uncaught ReferenceError: html is not defined

我究竟做错了什么?

4

8 回答 8

6

代码有两个问题。

  1. html 应该用引号引起来,因为它不是变量。

    $('html')
    
  2. 上课前不应该有一段时间

    .removeClass('ui-mobile');
    
于 2013-08-19T12:55:02.220 回答
2
$('html').removeClass('ui-mobile');
于 2013-08-19T12:56:19.857 回答
2

这是另一种使用prop节省几个字节的方法:

$('html').prop('class', '');
于 2013-08-19T13:02:30.367 回答
1

您需要使用元素选择器,其中元素名称必须作为字符串传递

$('html').removeClass('.ui-mobile');
于 2013-08-19T12:54:40.010 回答
1

您的声明意味着 html 是一个用引号括起来的变量,以将其用作标签选择器。还要删除.removeClass 方法中的点。

$('html').removeClass('ui-mobile');
于 2013-08-19T12:54:46.860 回答
1

试试喜欢

$('html').removeClass('ui-mobile');

它应该quotes

$('html')

并且不需要.在你removing或它时提及类名adding。它只在你选择它时需要,只需在你使用它时selector

于 2013-08-19T12:54:56.140 回答
1

试试这个

$('html').removeClass('ui-mobile');
于 2013-08-19T12:55:00.583 回答
0

它非常简单:-

$('html').removeClass('ui-mobile');

上述解决方案的解释:-

$('html') // 这是预定义的选择器

removeClass('ui-mobile'); // 从您定义的选择器中删除类。

您还可以添加类,例如:-

$('html').addClass('ui-mobile');

于 2013-08-19T15:28:37.640 回答