Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-05-04 16:26:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

[SOLVED] jquery add and remove Class does not work for me

Hi all,

I checked the net for this and a lot of people are asking but no answer is given.

I have this on the head

<script>
$(document).ready(function() {
$('body').removeClass('no-js').addClass('js');
});
</script>

but after examining the source code of the page, the no-js class remains. Could anyone tell me what I am doing wrong or if there is another method with jquery?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2015-05-04 16:30:48

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: [SOLVED] jquery add and remove Class does not work for me

How about using toggleClass instead: $("body").toggleClass("no-js js");

Offline

#3 2015-05-04 16:40:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] jquery add and remove Class does not work for me

Hi Pete, thanks but no toggleClass does not work either

I also checked it using this suggestion which returned an undefined response.

The site is online here


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2015-05-04 17:29:41

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [SOLVED] jquery add and remove Class does not work for me

How are you “examining the source code of the page”? A normal view source may not show changes made via javascript. Developer tools in Chrome, IE of Firefox should.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2015-05-04 17:46:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] jquery add and remove Class does not work for me

Hi Matt,

I have an <txp:rvm_if_privileged> class for a link to the individual article in the admin side, and a css with .js .hide {display:none}. The link is always displayed.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2015-05-04 17:55:44

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [SOLVED] jquery add and remove Class does not work for me

It seems to me that your jQuery 2.1.3 uncompressed isn’t complete. It shows me 2991 lines, but the uncompressed original has 9205 lines.

Offline

#7 2015-05-04 18:00:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] jquery add and remove Class does not work for me

GugUser wrote #290430:

It seems to me that your jQuery 2.1.3 uncompressed isn’t complete. It shows me 2991 lines, but the uncompressed original has 9205 lines.

Hi, I am using the minified one.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2015-05-04 18:03:49

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [SOLVED] jquery add and remove Class does not work for me

I see an incomplete uncompressed version with 2991 lines. Sorry, but I see that.

Offline

#9 2015-05-04 18:06:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] jquery add and remove Class does not work for me

GugUser wrote #290432:

I see an incomplete uncompressed version with 2991 lines. Sorry, but I see that.

Could you copy/paste and post the last line here please?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2015-05-04 18:08:56

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [SOLVED] jquery add and remove Class does not work for me

The five last lines:

    var Kc = a.jQuery, Lc = a.$;
    return n.noConflict = function(b) {
        return a.$ === n && (a.$ = Lc), b && a.jQuery === n && (a.jQuery = Kc), n
    }, typeof b === U && (a.jQuery = a.$ = n), n
});

But, something is strange, I will write it in the next post.

Last edited by GugUser (2015-05-04 18:09:13)

Offline

#11 2015-05-04 18:13:38

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [SOLVED] jquery add and remove Class does not work for me

I see in Safari an partial and uncompressed version. But, if I double click it, it opens with the URL neme-imca.org/js/jquery.js and shoes an seemingly compressed version. But if I decompress it, it isn’t complet.

Last edited by GugUser (2015-05-04 18:14:32)

Offline

#12 2015-05-04 18:53:55

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [SOLVED] jquery add and remove Class does not work for me

Your version has 96 608 B and isn’t decompressed correctly, the original jquery-2.1.3.min.js version has 84 320 B. Why do you not replace your version by the original version?

Offline

Board footer

Powered by FluxBB