javascript - Function to simplify code in jquery -


i have following code working:

$(document).ready(function () {     $(".b0").hover(function () {         var src = $(this).attr('data');         var href = $(this).attr('href');         $("#imagen").attr('src', src);         $("#vinculo").attr('href', href);     });     $(".b1").hover(function () {         var src = $(this).attr('data');         var href = $(this).attr('href');         $("#imagen").attr('src', src);         $("#vinculo").attr('href', href);     }); }) 

but can't simplify function. tried several times , ways...

you can use this:

 $(document).ready(function () {         $(".b0 , .b1").hover(function () {             $("#imagen").attr('src', $(this).attr('data'));             $("#vinculo").attr('href', $(this).attr('href'));         });     }) 

Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -