This is the situation:
Using eval makes it even easier. Use an index selector such as [0] with the jQuery code or it will return a collection of elements.
String elementLocator = "$('#btnID')[0]";
public RemoteWebElement getElementByJQueryLocator(String jQueryLocator){
JavascriptExecutor js = (JavascriptExecutor) driver;
RemoteWebElement element = (RemoteWebElement) js.executeScript("return eval(arguments[0]);", jQueryLocator);
return element;
}
RemoteWebElement webElement = getElementByJQueryLocator(elementLocator);
webElement.click();