/    Sign up×
Community /Pin to ProfileBookmark

addClass Problem with JavaScript

Hello, my name is Rafa. I am new here. My problem brought me here and hopefully someone could help me out with that. I found an outdated javascript on my computer which i want to implement on my website.
Well, at the moment its working, but when i update my CMS, the homepage will not work anymore and in my google console, there appears an uncaught TypeError: e(…).addClass is not a function at this code line:

[code]$(‘#cubeTransition>div:eq(0)’).addClass(‘visible’);[/code]

Unfortunatly i cannot solve this. I tried to change the line like people suggested to similar errors in different forums, i tried different setups with my CMS, but no progress. Standalone, without CMS it works fine, also no error appears in the google console.

i post the full code here:

[code]
(function($) {

var length = $(‘#cubeTransition>div’).length,
current = 1,
next = 1,
outClass, inClass, onGoing = false;
$(‘#cubeTransition>div:eq(0)’).addClass(‘visible’);

for (i = 0; i < length; i++) {
var bullet = $(“<li></li>”);
if (i == 0) bullet.addClass(‘active’);
$(“#bullets”).append(bullet);
}

function openIndex(i) {
if (!onGoing && next != i) {
onGoing = true;
next = i
outClass = current > i ? ‘rotateCubeBottomOut’ : ‘rotateCubeTopOut’
inClass = current > i ? ‘rotateCubeBottomIn’ : ‘rotateCubeTopIn’;
show()
}
}

function trans(direction) {
if (!onGoing) {
onGoing = true;
if (direction == ‘up’) {
next = current > 1 ? current – 1 : length;
outClass = ‘rotateCubeBottomOut’;
inClass = ‘rotateCubeBottomIn’;
} else {
next = current < length ? current + 1 : 1;
outClass = ‘rotateCubeTopOut’;
inClass = ‘rotateCubeTopIn’;
}
show();
}
}

function show() {
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).addClass(‘visible’);
$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).addClass(outClass);
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).addClass(inClass);
$(‘#bullets>li:eq(‘ + (current – 1) + ‘)’).removeClass(‘active’);
$(‘#bullets>li:eq(‘ + (next – 1) + ‘)’).addClass(‘active’);

animationOut(current – 1)
setTimeout(function() {
$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).removeClass(‘visible’);
}, 500)
setTimeout(function() {

$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).removeClass(outClass);
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).removeClass(inClass);
animationIn(next – 1)
current = next;
onGoing = false;
}, 600)
}

$(document).ready(

function() {

//for scroll by mouse or MAC track pad
var indicator = new WheelIndicator({
callback: function(e){
if (e.direction == ‘up’) {
trans(‘up’)
} else {
trans(‘down’)
}
}
});
indicator.getOption(‘preventMouse’); // true
//update this instead of mousewheel.js
//in issuses#2 a friend want to use this plugin on MAC track pad

$(document).keydown(function(e) {
if (e.keyCode == 38 || e && e.keyCode == 37) {
trans(‘up’)
}
if (e.keyCode == 39 || e && e.keyCode == 40) {
trans(‘down’)
}

});

$(document).swipe({
swipe: function(event, direction, distance, duration, fingerCount) {
if (direction == “up”) {
trans(‘down’)
} else if (direction == “down”) {
trans(‘up’)
}
}
});


$(‘#bullets>li’).on(‘click’, function() {
openIndex($(this).index() + 1);
});

});
})(jQuery);
[/code]

would be very cool if someone solves this. my solution would be in changing CMS or even without, but that is not a very timesaving solution.

thanks in advance

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@eor_designauthorSep 26.2022 — WOW what a great forum, the help is very quick here. thanks
Copy linkTweet thisAlerts:
@sibertSep 26.2022 — > @eor_design#1647452 the help is very quick here

Sorry there have been no answers to your question.

Normally you get quick responses. My personal view is that JQuery is somewhat outdated and sometimes vulnerable. And together with an unknown CMS, it may even harder to answer. And your code may be easier to follow if you add the HTML head (JQuery version). Hence there will be less answers.

Disclaimer: This is not a fact, just my personal opinion.

I suggest to try a targeted [JQuery forum](https://forum.jquery.com).
×

Success!

Help @eor_design spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...