Z
Z
ZaurK2017-04-06 21:24:05
css
ZaurK, 2017-04-06 21:24:05

How to give an element an existing css style?

Hello! I have a list of dynamically created divs

<div class="someclass">
    <div class = "item">1</div>
    <div class = "item">2</div>
    <div class = "item">3</div>
</div>

It is necessary to assign some .active class to the first element to get such a record . I would not want to touch js or jquery. Blocks are formed from php code in a loop. <div class = "item active">1</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Zhivagin, 2017-04-07
@ZaurK

Well, these are two lines on jQuery, do not complicate, especially if it is already connected to the project)

A
Alexander Pashkevich, 2017-04-06
@Ankell

$a=1;
while($a<10){
  if($a==1){
    echo '<div class = "item active">'.$a.'</div>';
  } else {
    echo '<div class = "item">'.$a.'</div>';
  }
}

But isn't that possible?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question