Hi friends, I have created the no.of div tags in my website applications.
Now i want to change the class name of the tags. How should I?
Below is some code which i want to change:-

<test.aspx>

<tr>
                <td style="width:100%;">
                    <div class="roundedcornr_box_203203">
                        <div class="roundedcornr_top_203203"><div></div></div>
                         <div class="roundedcornr_content_203203">
                        <iframe id="Graphframe" name="Graphframe" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;"  src="pgeGraph.aspx"></iframe>
                 </div>
                        <div class="roundedcornr_bottom_203203"><div></div></div>
                    </div>
                </td>
            </tr>

Now i want to change the class name at runtime using javascript
e.g. roundedcornr_box_203203 will be replaced by roundedcornr_box_408625 etc...
I need this very soon.
Thanks in advance

Recommended Answers

All 2 Replies

You can use the script at
http://code.google.com/p/getelementsbyclassname/
to get the list of elements of a given class name and than iterate through the list and change the className property of each element in javascript

Member Avatar for GreenDay2001

Get all elements with class name you want either by using getElementBYClass Name or using getAttribute(); and then change its name using setAttribute();. Can guarantee if this will really work well, so try it out.

For changing names in source, replace using Regular Expressions using your text editor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.