Reputation: 83
Is it correct to call a regular JavaScript function in a jQuery script or should it be external (it will only be access/used by the jQuery script)? I know that it works but I want to make sure that I am using best practice. For example:
$(function(){
$('.click1').click(function(){
dofunction();
}
$('.click2').click(function(){
dofunction();
}
function testing(grid_array){
alert('function works!');
}
});
Upvotes: 0
Views: 46
Reputation: 382274
jQuery is a JavaScript library adding facilities, most of them helping to deal with the DOM, AJAX, or crossbrowser issues. Your jQuery script is thus also a JavaScript one.
It's perfectly normal, recommended and fine to call non jQuery based functions from code made using jQuery. In fact, you could hardly avoid that.
Related: What is the difference between jQuery and JavaScript
Upvotes: 3