PDA

View Full Version : Delete css class from DOM element



JazzMan88
17 Jan 2011, 1:54 AM
Hi, i need to get DOM object when class = "x-date-middle" and this child class="x-btn x-hide-display x-btn-noicon". After I would like to delete "x-hide-display" class. I'm doing that:


b = Ext.select("*[class*=x-date-middle]").child("*[class*=x-hide-display]");
b.removeClass('x-hide-display');

It returns object but css class doesn't deleted. Where is error?

Condor
17 Jan 2011, 2:20 AM
Ext.select() returns a CompositeElement, child returns a single element, so 'b' will end up being a single element.

You want:

b = Ext.select(".x-date-middle .x-hide-display");
b.removeClass('x-hide-display');

JazzMan88
17 Jan 2011, 10:52 PM
Thanks, it works perfect but I understand.
This b = Ext.select(".x-date-middle .x-hide-display"), it's like a Ext.select("[parent] [child]"), or it returns all elements which contains this words in class name

Condor
17 Jan 2011, 11:39 PM
You should invest some time in reading about css selectors. That will not only help you with this, but it will also help you write better stylesheets.