Home > Web Front-end > JS Tutorial > JS method to implement DIV container assignment_javascript skills

JS method to implement DIV container assignment_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:25:53
Original
1583 people have browsed it

The example in this article describes how to implement DIV container assignment using JS. Share it with everyone for your reference, the details are as follows:

Assign a js function to a DIV container, used in ajax, supporting IE and Firefox

<script>
function setValueForDiv(id,content)
{
 var element = document.getElementById(id);
 element.innerHTML = unescape(content);
 if(!element.innerHTML)
 {
  try{
   element.innerHTML = unescape(content);
  }catch(e){}
 }
}
</script>

Copy after login

where id is the id of the div
content: for content

Call example:

<div id="title"> </div>
setValueForDiv(id,content)
<script>
 setValueForDiv("title","this is a test");
</script>

Copy after login

I hope this article will be helpful to everyone in JavaScript programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template