Reputation: 809
I have 50 divs that have all the same class (.marker), and an id (#a1, #a2, ...).
Now I want, that if I hover over such a div a JavaScript function is called that returns the css-left attribute of the specific div:
function(divId){
return $(divId).css("left");
}
And I don't know how to do that without having to write a function call to every div. I thought of something with this.css("left"), that saves me typing work.
Thanks for your help in Advance...
Upvotes: 0
Views: 51
Reputation: 30557
You can't return a value from a click handler. But, you can change your approach to changing a variable
var currentLeft;
$('.marker').hover(function(){
currentLeft = $(this).css('left');
});
Upvotes: 3