How can I get the CSS Selector in Chrome?

前端 未结 5 1595
小鲜肉
小鲜肉 2020-11-28 09:12

I want to be able to select/highlight an element on the page and find its selector like this:

div.firstRow div.priceAvail>div>div.PriceCompare>div.B

5条回答
  •  再見小時候
    2020-11-28 09:33

    The workflow I currently follow to get CSS selectors from elements with the latest Chrome version (59) is as follows:

    1. Open Chrome Dev tools (cmd/ctrl + alt + j):

    1. Click on the select element tool in page (cmd/ctrl + alt + c):

    1. Click on the element you want to get the selector from in order to view it in the dev tools panel:

    1. Right click on the dev tools element:

    1. Click on Copy -> Copy selector:

    Which gives me the following:

    #question > table > tbody > tr:nth-child(1) > td.postcell > div > div.post-text > blockquote > p

提交回复
热议问题