Reputation: 91
I want to maintain the width of an element on hover. Basically, I have put my width properties in array and want to access them when I hover it's element. Here is my code:
var tabs = $('.tab-block li').map(function(){
return $(this).css('width');
}).toArray();
$('.tab-block li').hover(function(){
$(this).css({'width': tabs[GET_HOVERED_ELEMENT_WIDTH]});
},function(){
$(this).removeAttr('style');
});
Upvotes: 0
Views: 73
Reputation: 140236
Have no idea what you are doing here but you can do something like this:
$('.tab-block li').hover(function(){
$(this).css({'width': tabs[$(this).index()]});
},function(){
$(this).removeAttr('style');
});
Upvotes: 1