jquery each function not working in sharepoint -
in order center of excel app web parts on sharepoint 2013 sp1 page, thought use jquery so. tried following code handle horizontal centering. unfortunately function seems never called.
i expect 9 alert() since there 9 divs on page matching selector. in other words there 9 divs class="ewr-sheetcontainer ewr-grdblkcontainer ewa-scrollbars". yes has 3 classes , css allows type of selection maybe jquery not.
this code embedded on page , jquery enabled site collection.
does see problem script, function, or way each called? goal adjust left attribute 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>
try this, seem missed dots specifying classes.
$(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; }); });
Comments
Post a Comment