A js question. I hope you can help me find a layer called & lt; divclass = & quot; demo & quot; & gt; he wants to use js to set class = & quot; replace demo & quot; with id = & quot; demo & quot; But varstr = & quot; with a js question. please help me.
I have a layer called
He wants to use js to replace class = "demo" with id = "demo"
But var str = "" How can I write it here?
------ Solution --------------------
Find the object, obj. id = 'demo'; obj. className = '';
------ Solution --------------------
You already have an id, right?
?
To change
------ Solution --------------------
The problem is answered! Please
Document. body. innerHTML = document. body. innerHTML. replace (/class = demo/I, 'id = Demo ');
This is a simple way of writing. I will give you some ideas.
For complex and complete solutions, go to web development-javascript layout
------ Solution --------------------
So I am asking him what the problem is. haha
------ Solution --------------------
Jquery
$ ('. Demo'). attr ('id') = 'demo ';
------ Solution --------------------
Discussion
The problem is answered! Please
Document. body. innerHTML = document. body. innerHTML. replace (/class = demo/I, 'id = Demo ');
This is a simple way of writing. I will give you some ideas.
For complex and complete solutions, go to web development-javascript layout
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