0

first I'm sorry but the fiddle will not work because the problem is about a code applied on a free forum platform unmanageble file-per-file because it is entirely hosted forumcommunity.net, and for its security, their owners disabled by default MANY JS Features (the most important), the PHP and the "$" for jQuery. Now, there is a workaround but I'll give you the corrected code:

http://jsfiddle.net/rTbhh/2/

The problem is with

objs.o.on("click", function() { $(".color").css("font-size", "-="+objs.val); });

It seems to not working because -= seems to not exist but on jQuery docs there's a reference about the use of += and -= in .css function. I tried this also in Google Chrome js Console.

Any ideas? Thank you.

3
  • What is objs and (by extension) objs.val? Commented Jun 29, 2014 at 22:29
  • @NiettheDarkAbsol objs is an object with, inside, N, O, VAL and ACTUAL "variables". Commented Jun 29, 2014 at 22:41
  • 1
    @AlexanderO'Mara what? What do you mean? It doesn't work? Commented Jun 29, 2014 at 22:41

1 Answer 1

1

You should provide better examples, I actually had to write half of your fiddle to make it work.

What happens is that += and -= in jQuery take integer arguments, rounding respectively up and down. So when you have .5 for your val, the font-height is increased by 1 and decreased by 0.

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

9 Comments

Thank you for answering me. You are saying that my code is "a little bit" wrong? So, what I have to do?
in fact it's both increased and decreased by 0, I doubt that font-size can only be an interger (otherwise it will be rounded). This += and -= in jQuery take integer arguments appears to be wrong, because if you try with opacity (instead of font-size), it will accept a float number.
@AlexanderCerutti your code is wrong in how you increase and decrease the font-size, the minimum increment/decrement is 1, but you used 0.5. After setting font-size = font-size + 0.5, it's in fact rounded to font-size which is unchanged, so it won't work. If you change 0.5 to 0.8, it in fact works but the actual increment/decrement is 1 (rounded from 0.8) (not 0.8).
This is the situation: I'm in a forum where some classes and Ids are defult; some of them could be edited, others no. The class mini_buttons is where "Edit topic" and "Quote answer" are. So I prepend 2 buttons: A+ and A- Now, when I click one of them, the font of .color (the class that defines topic text css properties) get increased and decreased. I can't use opacity because I don't need them. I need only to increase the font and decrease it, but -= doesn't work (tried also in pure javascript). Anyway thankyou @KingKing.
@KingKing Yep, I am wrong and you are correct about the opacity. This is what I got from fiddling with the fiddle - when I put the value to 1.5 it increased the font by 2 and decreased it by 1 for every click. Beats me! AlexanderCerutti just change your val variable to some integer and you'd be fine
|

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.