I'm in the middle of writing a phonegap app that contains a database, much like this. I want to put a search function in it that, after putting in your search term, scans the html for and id tag and then redirects you to that id. How would I go about doing this? I've done m开发者_StackOverflow中文版y research and can't find any adequate jQuery or PHP solutions.
Thanks in advance!
If I understand you correctly you are just searching for an ID within the DOM?
If using jQuery it would look something like...
var search = //However you are doing your search result
var elementId = $('#'+search); //The # means you are searching for an ID. If it was a class you could use a .
The above will store the targeted element in the variable "elementId". You can choose what you want to do with it after that.
And if you are using the ScrollTo jQuery Plugin you can do...
$.scrollTo(elementId);
Which will cause the window to scroll to the element found.
I hope that helps.
精彩评论