动态添加按钮(jQuery) [英] Add button dynamically (jquery)

查看:73
本文介绍了动态添加按钮(jQuery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对jquery和Ajax进行分页. 我遇到的第一个问题是如何添加按钮

I want to make pagination with jquery and Ajax. The first where I'm stumbling on is how I can add a button

<div class="btn-group" id="pagination_group">
        <button class="btn" disabled="disabled">First</button>
        <button class="btn" disabled="disabled">Prev</button>
        <button class="btn btn-primary" id="p1">1</button>
        <button class="btn" id="p2">2</button>
        <button class="btn" id="p3">3</button>
        <button class="btn" id="p4">4</button>
        <button class="btn" id="p5">5</button>
        <button class="btn" id="next">Next</button>
        <button class="btn" id="last">Last</button>
    </div>

append()有什么问题? 但是如何在正确的地方找到它呢? 这个想法是在单击下一步"之后,删除id ="p1"的btn(没问题),并在button5和按钮Next之间添加id ="p6"的按钮.

Something with append()? But how to get it it the right place? The idea is after click on Next remove btn with id="p1" ( that's no problem) and add button with id="p6" between button5 and button Next.

谢谢您的建议.

推荐答案

可能有几种方法可以实现此目的.参见此工作示例

Possibly several ways to accomplish this. See this working example

这篇关于动态添加按钮(jQuery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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