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

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -