I have a object which i looked from firebug looks like following
var object looks like in firebug = [li#demo0 .demo]
similarly it can be
[li#demo1 .demo]
I am sure demo1 is the id of li and .demo is the class. Now I want to get the id from this object i.e demo1.How can i do this in javascript.?
If you know its always going to have the class of “demo” its nice and easy 🙂 Im assuming your using jQuery (As youve tagged it)
Here is an example:
http://jsfiddle.net/HenryGarle/dxbhp/
It selects anything with the class of “demo” and then gets the id. If you have multiple elements with the class of demo this would not be suitable but I’m assuming you have not as you’ve not mentioned it.