1

this is the css we do

width: 200px;
height: 100px;
background-color: #f00;

and when we want to give no-more-use of the css we could add just a slash or anything that css doesn't understand but all other css works

widt/h: 200px;
height: 100px;
background-color: #f00;

but I wanted to do it in jquery like marginLef/t in jquery which didn't work anymore all other params.

sample jquery

<script>
$(document).ready(function(){
  $("button").click(function(){
    $("h2").animate({backgroundColor: '#00f', width: '-=150px', marginLef/t: '50px'});
  });
});
</script>
8
  • 1
    why don't you just delete it ?? Commented Jun 11, 2013 at 10:09
  • this would be in use next time. Commented Jun 11, 2013 at 10:10
  • Show please jquery code, that you tried. Commented Jun 11, 2013 at 10:10
  • 3
    why don't you just comment out the unused parts? /* comments are your friends */ Commented Jun 11, 2013 at 10:10
  • 1
    @C-Link, try to set "margin-lef\t" (in quotes) instead of marginLef\t Commented Jun 11, 2013 at 10:12

2 Answers 2

1

Instead of breaking your code, use comments. For CSS:

/* width: 200px; this rule is obsolete for now */
height: 100px;
background-color: #f00;

In Javascript:

alert('this line is executed');
// alert('this line is not');
/* removed following line in a multiline comment
alert('also not being executed');
*/

Commenting ensures the values are not being parsed as a whole, and that it cannot break the parser/compiler and as such other functionality.

While CSS standards explicitly define that a malformed rule should be ignored, and other valid rules still applied, in a compiler language like Javascript it just breaks execution as a whole.

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

1 Comment

I know the way we comment but I have put this question so that next time jquery developer will solve this problem.
0

Wouldn't it be easier by making two different classes, other with the width and one without. Then just change the elements' class with jQuery using addClass and removeClass or toggleClass.

Comments

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.