1
var helper, kitti, amount;
if (i == 0) { 
    helper = "#k" + ids+ " .contain";
}
else {
    helper = "#k" + ids + " .d" + i;
}    
kitti = "$(" + helper + ").get(0)";
amount = (MouseX-kitti.width / 2) * layer[i - 1] * 2;
kitti.style.transform = "rotateY(" + amount * 50 + "deg)";
kitti.style.left = amount + "px";

This part of my code doesn't seem to work but. I bet I did something wrong selecting it? I've read a couple of articles and I came to this conclusion. But it does not work, can you explain me why? How can I select classes with jQuery and after that continue with plain Javascript?

6
  • 4
    Try: kitti=$(helper).get(0) Commented Feb 21, 2013 at 19:50
  • could you try posting better formatted code Commented Feb 21, 2013 at 19:53
  • This asker mentions on his SO homepage that he is a hobbyist programmer. We can't expect him to know all the ins and outs of how to properly format code, so let's be gentle and helpful as much as possible. Commented Feb 21, 2013 at 19:55
  • Thanks man that helped! I have made some other mistakes too, but corrected them. Commented Feb 21, 2013 at 19:58
  • If an answer provided solves your problem, please click the checkmark next to the answer to mark it as the "accepted" solution. Commented Feb 21, 2013 at 20:02

1 Answer 1

3

You've made some simple syntax errors here. I personally don't care for the style in which you're written your code, but I will do my best to suggest what the fix might be.

In the second line, you write kitti = "$(" + helper + ").get(0)". The problem here is that $ is a function defined in the jQuery library and you are treating it as a string.

The result here will be to assign a string value to the variable kitti. You also appear to be using an undefined variable ids in line 1. The correct syntax would be something like this:

var kitti = $(helper).get(0);

I don't want to be overbearing, but from the syntax of the code in your question, you might benefit from reading a book on good JavaScript such as "JavaScript: The Good Parts", by Douglas Crockford. There is also lots of good information available for free on his web site.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 for javascript the good parts. Movie version here youtube.com/watch?v=hQVTIJBZook
I've watched many of Crockford's lectures on the "YUI Theater"; some of the best JavaScript learning experiences ever, IMHO. @dawe69hun would be well advised to be aware that JavaScript has a unique design and history that make it quite different from many other popular languages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.