javascript - Add class to element depending on which side of the screen its on -


i making timeline theme , need have separate class posts on right side of screen , left side of screen. don't see wrong javascript of course not working.

var halfscreenwidth = jquery(document).width() * 0.5; var timelinepost = jquery('.blog .post');  jquery(document).ready( function(){     timelinepost.each( function(){        if( this.position().left < halfscreenwidth ){            jquery(this).addclass('timeline-left');        } else{            jquery(this).addclass('timeline-right');        }     }); }); 

made few modifications @ https://jsfiddle.net/zlv4s0ur/26/ .

if( this.position().left < halfscreenwidth )

should

if( jquery(this).position().left < halfscreenwidth )


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -