Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 17:43:26
Original
1173 people have browsed it

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!
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template