jQuery在元素之前 [英] jQuery Prepend before an element

查看:63
本文介绍了jQuery在元素之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的html结构/

I have a html structure like this/

<li id="1"></li>
<li id="2"></li>
<li id="3"></li>
<li id="comment-box"></li>

现在我想假装

<li id="4"></li>

在评论框之前.

我正在从评论框中提交表单,一旦成功,我想做一个前缀.

i am submitting a form from the comment box and once its a success i wanna do the prepend.

推荐答案

使用 before():

$('#comment-box').before('<li id="4"></li>')

这篇关于jQuery在元素之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆