• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting css selector string of an element from html dom

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am working on an application which works only in chrome. I dont see XPath addon working to get css selector.
I see some methods in Java console and tried giving document.getelemenentbyclass["ABC"] for one of the elements and it worked. But to identify elements in a dynamic grid class name is not unique, so I am trying to get css selector string combining some other values I see in HTML DOM. Can you help me in figuring out how I can extract a css selector



 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.getElementsByClassName("className") returns an array of elements with that class name. You must loop through them to change them.



Note: document.getElementsByClassName does not work in IE 6,7,8



I would recommend using jQuery to get those and loop through them to manipulate them as you have a lot more that you can do with the elements.

You could also check into datatables plugin to jQuery if you are wanting to work with a dynamic grid of data.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic