A JS related issues, I hope you help

Source: Internet
Author: User
A JS question, I hope you help
I have a layer that is called

He wants to use JS to replace class= "demo" With Id= "demo"

But var str= "" How to write here?

------Solution--------------------
First find the object, obj.id= ' demo '; Obj.classname= ";
------Solution--------------------
You already have an ID, don't you?
?
To modify into
------Solution--------------------
See clearly the question in reply! Come on

Document.body.innerHTML = Document.body.innerHTML.replace (/class=demo/i, ' Id=demo ');
This is a simple way of writing, to give you a clue
Complex and perfect please go to Web Development ――javascript Layout Solution
------Solution--------------------
So I was asking him what was the problem. haha
------Solution--------------------
Jquery
$ ('. Demo '). attr (' id ') = ' demo ';
------Solution--------------------
Explore

See clearly the question in reply! Come on

Document.body.innerHTML = Document.body.innerHTML.replace (/class=demo/i, ' Id=demo ');
This is a simple way of writing, to give you a clue
Complex and perfect please go to Web Development ――javascript Layout Solution
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.