Javascript Expected Identifier Error On Internet Explorer

I googled a little and found this could happen if you included an extra comma in some expressions but that wasn’t my case.

Some coffees later I found the offending code was:

var class = $(this).parent().attr('class');

Yep, class seems to be a reserved word in Internet Explorer, thanks again Microsoft for making web developers lifes so difficult.

I just changed the variable name to fix the error, something like this:

var tabClass = $(this).parent().attr('class');

A little later I found another mention of the class problem, hell!, where was this article when I was looking for the fix? It seems you can’t set classes with jQuery’s attr() method in Internet Explorer either, well, I guess that’s why we have addClass() and removeClass().

Jquery bind, multiple events div

<div class=”test”><div class=”inside”><h1>id=”myID.entry[0]”</h1><p>0</p></div></div>

<script>$(“div.test”).bind({
click: function(){
$(this).addClass(“active”);
//alert(this.nodeName);
//alert($(this).text())

},
mouseenter: function(){
$(this).children(‘div.inside’).animate({
top: “20px”,
}, “fast”);
},
mouseleave: function(){
//$(this).fadeIn();
$(this).children(‘div.inside’).animate({
top: “100px”,
}, “fast”);
}
});</script>

How To Optimize Your Site With GZIP Compression .htaccess

Setting up the server

The “good news” is that we can’t control the browser. It either sends the Accept-encoding: gzip, deflate header or it doesn’t.

Our job is to configure the server so it returns zipped content if the browser can handle it, saving bandwidth for everyone (and giving us a happy user). Continue reading “How To Optimize Your Site With GZIP Compression .htaccess”