Jump to content
  • 0

добавление класса


dostel1
 Share

Question

всем привет!

есть проблема!

есть <div class="one"></div>

нада искать по классу этот элемент и добавить к нему еще один класс чтобы вышло

<div class="one two">!!Помогите реальным примером

Всем пасиб

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

var div=document.getElementsByTagName('div');
for (var k=0; k < div.length; k++)
if (div[k].className=='one') div[k].className='one two';

document.getElementById('pk').className.replace('/\bone\b/' ,'one two')
Это нужно кому-то присвоить. Сама по себе операция со строкой не меняет эту строку.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy