i have a file where i call functions collectively. This file contains the following code. i get error on non-library(jquery.barrating.min.js) pages running this code. error i got "barrating is not a function error".
how can i get the code to run if only this function exists?
$(function() {
$('#example').barrating({
theme: 'fontawesome-stars'
});
});
CodePudding user response:
If you want to run this code only if this function exists, you can test its presence in the jQuery prototype:
if (jQuery.prototype.barrating) {
// Your code goes here
}
