Skip to content

Instantly share code, notes, and snippets.

@gilbox
Created November 27, 2013 21:21
Show Gist options
  • Save gilbox/7683414 to your computer and use it in GitHub Desktop.
Save gilbox/7683414 to your computer and use it in GitHub Desktop.
Get a jQuery selector for any element on a page in Chrome (or any WebKit browser). [assuming jQuery has been loaded on the page]
// right-click any element and choose copy xpath, it will look something like this:
//*[@id="list-results"]/div[2]/div[1]/div/ol/li[5]/div/a
var MY_XPATH = '//*[@id="list-results"]/div[2]/div[1]/div/ol/li[5]/div/a'
// then do this:
$($x(MY_XPATH))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment