简体   繁体   中英

can you find html element by attribute with csquery

Can I use csquery to find a html with a certain attribute with a certain value.

So if I got a page where there is something like this

<html>
   <body>
      <div align="left">something</div>
   </body>
</html>

Can I then get the hole line out by search for a div with the attribute align with the value left? or even just the html element, and then get the value from within the attribute?

As always, thanks for the help and time.

I haven't used csquery myself but when looking at the docs, and you can use css queries this should work

div[align='left']

EDIT: After being assured that this is in response to a client side operation, in the script it should look like this:

var rows = query["div[align='left']"];

This how you can look up elements by tag and attribute selectors, is to have the attributes you want in brackets. and then the value interpolated like so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM