I have an image map that contains strings of places. When the user clicks on certain areas, a string (depending on wherever was clicked) will be sent to a function that needs to scroll to a hidden input who's id equals that string.
<input type="hidden" id="Nashville, TN">
<div class="speaking-date">...</div>
there are multiple divs that contain no id's and I can't give them id's so I created hidden inputs above each id with the desired string. So if the user clicks on Nashville, TN on the image map, I want it to scroll to the hidden input with the id Nashville, TN.
function FindPlace(place){
var $j = jQuery.noConflict();
$j('html, body').animate({
scrollTop: $j("#"+place).offset().top
}, 2000);
}
variable place being wherever they clicked.
scrollTop: $j("#"+place).offset().top
I get the error "Cannot read property 'top' of undefined".
I tried using:
scrollTop: $j( "input[id="+place+"]" ).offset().top
but I get the error "Syntax error, unrecognized expression: input[id=Nashville, TN]". I'm doing this on Wordpress which is why I'm using noConflict. Any help or tips would be appreciated.