用jQuery重命名Bootstrap选项卡 [英] Rename Bootstrap Tab with jQuery

查看:95
本文介绍了用jQuery重命名Bootstrap选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个使用jQuery动态创建新标签的系统,这样当点击一个链接时,它会创建一个新标签。每个选项卡的内容都设置为文本框。是否有可能将标签的标题更改为文本框中输入的内容,理想情况下是因为它们需要输入而不是必须点击输入或另一个按钮之后才能输入?

I have set up a system to create new tabs dynamically using jQuery, so that when a link is clicked it creates a new tab. The content of each tab is set as a textbox. Is it possible to change the title of the tab to what is entered into the text box, ideally as they type and not after having to click enter or another button?

I也有另一个问题,我不确定这是否需要一个新的问题,但无论如何这里。我需要能够删除标签,理想情况下点击链接。我认为这是可能的,但我不确定如何。到目前为止,我已经想到了一个jQuery函数,您可以将标签的id传递给它,并删除链接和内容,但我真的不知道如何编码它?

I also have another problem, I'm not sure if this needs a new question or not but here goes anyway. I need to be able to also delete tabs, ideally when clicking a link. I gather that this is possible but I'm not sure quite how. So far I have thought of a jQuery function where you pass the id of the tab to it and it deletes the link and the content but I don't really know how to code it?

jsFiddle:
http://jsfiddle.net/BenedictLewis/eYePA/

jsFiddle: http://jsfiddle.net/BenedictLewis/eYePA/

Info:
I am using Twitter Bootstrap with the theme Simplex from Bootswatch.
The CSS and JS files for Bootstrap are loaded from BootstrapCDN.


推荐答案

试试
$ b ('keyup','input [id ^ =pageTitle_tab]',function(){
var index($ key)',$ b

Try

$('#tabContent').on('keyup', 'input[id^="pageTitle_tab"]', function(){
    var index  = $(this).closest('.tab-pane').index();
    $('#tabHeaders li:eq(' + (index + 1) + ') a').html(this.value)
})

演示:小提琴

这篇关于用jQuery重命名Bootstrap选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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