-1

I wan to add a css class for all elements that has particular style.

Eg. if there are 5 elements that with the style "float:left".

I want to remove the "float:left" and add "align-left" class.

please help me

Linesh jose
  • 53
  • 1
  • 5

2 Answers2

1

The way to do it is to use filter() like below, but the target selector * is a bad one, so try to have better selector to target the desired elements

$('*').filter(function () {
    return this.style.float == 'left'
}).css('float', '').addClass('align-left')
Alnitak
  • 334,560
  • 70
  • 407
  • 495
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

You can also use this:

if( $("#test").css('display') == 'block') {
  // Remove and add properties here
}

Thanks to Pekka in his answer to this SO question!

Community
  • 1
  • 1
Sidney Gijzen
  • 1,931
  • 3
  • 24
  • 27