I have a CQWP that executes the following JS:

var projectstartdt = $(".hiddenProjectStartDate").html().split(/\-|\s/);
var ProjectStart = new Date(projectstartdt.slice(0,3).join('/')+' '+projectstartdt[3]);

var projectenddt = $(".hiddenProjectEndDate").html().split(/\-|\s/);
var ProjectEnd = new Date(projectenddt.slice(0,3).join('/')+' '+projectenddt[3]);

var milestone1date = ((Milestone1Date-ProjectStart)/(ProjectEnd-ProjectStart)*100);
$(".wj-cqwp-ProjectMilestone1").css( "left", milestone1date + "%");

var milestone2date = ((Milestone2Date-ProjectStart)/(ProjectEnd-ProjectStart)*100);
$(".wj-cqwp-ProjectMilestone2").css("left", milestone2date + "%");

This code isn't the problem. It's working as expected. Problem is, I need this to fire for every li within a CQWP. Specifically every

.wj-cqwp-ProjectDashboard ul li

I've tried using a jQuery each function, but to no avail!

$( ".wj-cqwp-ProjectDashboard ul li" ).each(function() {
// big chunk of code above entered here

Help! Please!


You may need to wrap or delay that function until SharePoint controls finish loading that with _spBodyOnLoadFunctionNames:


function fireOnListItems(){

$( ".wj-cqwp-ProjectDashboard ul li" ).each(function() {
// big chunk of code above entered here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.