Home  >  Article  >  Web Front-end  >  jquery prepend函数实例

jquery prepend函数实例

WBOY
WBOYOriginal
2016-06-01 09:54:571197browse

首先介绍一下prepend函数的语法:

语法

<code class="language-javascript">$(selector).prepend(content)</code>

其中,content 必需。规定要插入的内容(可包含 HTML 标签)。

实例:

<code class="language-html">

<script type="text/javascript" src="http://www.manongjc.com/Public/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#manong").click(function(){
        $("#content").prepend('码农教程');
        });
    });
</script>


<div id="content" style="border:1px #ccc solid">这是原来内容。</div>
<button id="manong">插入文本</button>

</code>

在线运行

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