Home  >  Article  >  Web Front-end  >  Try making the type attribute of script equal to text/html_javascript trick

Try making the type attribute of script equal to text/html_javascript trick

WBOY
WBOYOriginal
2016-05-16 17:43:261113browse

We can define a code called by JS in the <script> fragment, but the code is not displayed on the page. In this case, we can use the following method: <br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="89495" class="copybut" id="copybut89495" onclick="doCopy('code89495')"><u> Copy the code </u></a></span> The code is as follows: </div> <div class="codebody" id="code89495"> <br><script id="commentTemplate" type="text/html"> <br><li> <br> <div class="photo"> <br><a href="#"> <br><img src="[UserImg]" /></a></div> <br><p> <br><a href="#">[UserName]:</a><span class="time">[CreateDate]</span></p&gt ; <BR><div class="clear"> <br></div> <br></li> <br></script>


Copy code The code is as follows:






OK, this means that when you click the button , you can chase the content of commentTemplate into comment_ul_2. This is very interesting, haha!

And there is a replace, which is also very interesting. When replacing, you can accept a json string, and then compare the key in the js module according to the json key to assign the value!
Really interesting!
Statement:
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
Previous article:Problems encountered in FireFox when using JS to submit parameters to create a form_javascript skillsNext article:Problems encountered in FireFox when using JS to submit parameters to create a form_javascript skills

Related articles

See more