in order to center all of the excel app web parts on a sharepoint 2013 sp1 page, I thought I could use jquery to do so. I tried the following code to handle horizontal centering. unfortunately the function seems never to be called.
I would expect 9 alert() since there are 9 divs on the page matching the selector. in other words there are 9 divs with the class="ewr-sheetcontainer ewr-grdblkcontainer ewa-scrollbars". yes it has 3 classes and css allows this type of selection but maybe jquery does not.
this code is embedded on the page and jquery is enabled for the site collection.
does anyone see a problem with the script, function, or the way each is called? the goal is adjust the left attribute for the selected div.
<script type="text/javascript">
$(document).ready(function() {
$("div.ewr-sheetcontainer ewr-grdblkcontainer ewa-scrollbars").each( function () {
this.css("position","absolute");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
$(window).scrollLeft()) + "px");
alert("hello");
return this;
} );
});
</script>