摘要 |
The invention relates to a JQuery selector acquisition method and a JQuery selector acquisition device. The method comprises the following steps of: searching a tag selector, a class selector, an attribute selector and/or an element selector for a page element; when the tag selector does not exist and the class selector or the attribute selector does not meet the uniqueness of the selector, pushing the class selector or the attribute selector which does not meet the uniqueness of the selector into a selector stack of the current element; searching the tag selector and/or the class selector of an ancestor element in a set number of stages; and after searching the tag selector of the ancestor element in the set number of stages or when the set number of stages is reached, pushing the tag selector of the ancestor element into the selector stack and acquiring a JQuery selector of the page element from the selector stack. The JQuery selector acquisition method and the JQuery selector acquisition device realize that the selector input by a user is checked under a plurality of browsers and the JQuery selector of the page element can also be reversely acquired. |