jquery after_jQuery after()

jquery after

jQuery after method can be used to add HTML content, DOM element, or jQuery object to insert after each element in the set of matched elements. We can also have function in jQuery after method that returns content to add after the set of matched elements.

jQuery after方法可用于添加HTML内容,DOM元素或jQuery对象,以在匹配的元素集中的每个元素之后插入。 我们还可以在jQuery中的after方法中提供函数,该方法返回要在匹配的元素集之后添加的内容。

jQuery之后 (jQuery after)

jQuery after method is same as insertAfter() and the difference is in the syntax with the placement of target element and content to add.

jQuery after方法与insertAfter()相同,不同之处在于语法上带有目标元素和要添加的内容的位置。

Here is an example page where I am dynamically adding new paragraph and text box in HTML page using jQuery.

这是一个示例页面,其中我使用jQuery在HTML页面中动态添加新的段落和文本框。

<html>
<head>
<title>jQuery after() Examples</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script>
function addNewParagraph(){
	$("p:first").after("<p background-color=red>Dynamic Paragraph</p>");
}

function addNewTextbox(){
	$("input:text:last").after("<br><input type='text' name='text2'>");
}
</script>
</head>
<body>
<p>First Paragraph</p>
<input type="button" onclick="addNewParagraph()" value="Add Paragraph">
<br><br>
<input type="text" name="text1">
<br>
<input type="button" onclick="addNewTextbox()" value="Add Textbox">
</body>
</html>

之后的jQuery –自己尝试 (jQuery after – Try it Yourself)

演示地址

翻译自: https://www.journaldev.com/1040/jquery-after

jquery after

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值