I'm new to javascript and jquery, but I know a few things and there's something intriguing me because I don't know if this is a bad thing to do or not. Is it bad to make use of $(document).ready
for example or repeat the same function multiple times like this:
$(document).ready(function(){
$(".Button-1").click(function(){
$(".contente-1").slideToggle('fast');
});
});
$(document).ready(function(){
$(".Button-2").click(function(){
$(".contente-2").slideToggle('fast');
});
});
$(window).bind("load", function() {
// code here
});
$(window).bind("load", function() {
// another code here
});
Can this create conflicts, make the website slower or have a bad behave for the script? or this is the right way to do it?
I know I could do this in one single button or $(document).ready
instead of creating two functions, but what I'm trying to understand is if it's bad repeating them many times like this
Aucun commentaire:
Enregistrer un commentaire