I needed to put my script after the body tag to make sure that my script runs after all the elements are loaded. I would greatly appreciate your help.
$(document).ready(function() {
$(document.body).prepend(
console.log('test8');
//custom jquery
if ($('div.fc-bg table').length > 0) {
var holiday = ['2016-12-01','2016-12-23','2016-12-30'];
$.each(holiday, function(i, val) {
var date = val; //'2016-12-01';
$('.fc-day-top[data-date='+date+']').addClass('holiday');
});
} //end of custom jQuery
)};
});
Thanks in advance.
I will recommend you to use $(document).ready() event for purposes like this. And no need to append a script after body tag. You can put is anywhere in body element. For more info see documentation here: https://learn.jquery.com/using-jquery-core/document-ready/
I needed to put my script after the body tag to make sure that my script runs after all the elements are loaded.
To ensure that all the elements are loaded before your script runs, you need to put your <script>...</script>
at the end of the document body, just before </body>
.
For a belt-and-braces approach do also use $(document).ready();
like so:
<html>
<head>
[... HEAD CODE HERE...]
</head>
<body>
[... BODY CODE HERE...]
<script>
$(document).ready(function(){
[... JQUERY CODE HERE...]
});
</script>
</body>
</html>
Use the eventAfterAllRender
event
eventAfterAllRender:function(){
//custom jquery
if($('div.fc-bg table').length > 0 ){
var holiday = ['2016-12-01','2016-12-23','2016-12-30'];
$.each(holiday, function(i, val){
var date = val;//'2016-12-01';
$(".fc-day-top[data-date="+date+"]").addClass('holiday');
});
} //end of custom jquery
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.