I have a scrolling plugin which after initialization stores the scroll amount in the specific id.
I am using jQuery to get the id of the div and storing it in variable bid.
var bid = $(this).parent().parent().find(".video_s").attr('id');
In console var bid returns the element ID. (This Works correctly)
As the scroll amount is stored in objects specific to DOM element IDs
var bpos = bid.scrollData.scrollPosition[0][0];
THE ABOVE CODE IS NOT WORKING
variable bid contains the id of the element.
If i type elementID.scrollData.scrollPosition[0][0] in console, it perfectly returns the scroll amount. where elementID is the specific ID if the horizontal container.
Please can anybody tell me whats wrong?
SOLUTION 1:
window[bid].scrollData.scrollPosition[0][0]
SOLUTION 2:
eval(bid).scrollData.scrollPosition[0][0]
NOTE: never use eval(). eval() is slow and a security risk
Since
bidis only the string containing the element-id but you need a jQuery Object containing the actual dom-element, the code should be:$('#'+bid)gets the element according to ID stored in bid.In the case of this plugin the elements are stored in a global variable (which is btw. very bad programming style), so you can use the following to access them: