Tag: 追加

jQuery在Selected选项卡上添加类

我是jQuery的初学者,我正在尝试修改脚本。 脚本演示在这里 。 现在,他们在所选标签上方添加一行,我不想要。 我想要做的只是添加一个类到锚点 Tab Name 这样我就可以使用CSS来改变活动按钮的背景颜色或其他东西。 以下代码是您单击选项卡时的当前代码。 the_tabs.click(function(e){ /* “this” points to the clicked tab hyperlink: */ var element = $(this); /* If it is currently active, return false and exit: */ if(element.hasClass(‘.active’)) return false; $(this).addClass(‘active’)

如何在值为空时隐藏附加的输入名称

大家好,我有一个小脚本,将输入值列表及其名称附加到textarea中。 我想要做的是在值为0或empty时隐藏字段名称。 这是脚本: function showValues() { var fields = $(“.content :input”).serializeArray(); $(“#contentlist_copy”).empty(); jQuery.each(fields, function(i, field){ $(“#contentlist_copy”).append(field.value + ” ” + field.name + “, “); }); } $(“input”).change(showValues); showValues(); 我知道这是一个基本问题,我感谢你的帮助。

$ .Ajax .Append在Safari(iOS和OSX)上无法正常工作

Gooday 经过很多头疼,我转向你们寻求帮助。 我在一个方形空间页面上使用jQuery MixItUp – 但最近我遇到了代码块限制为300.000个字符的问题。 我的解决方案是附加一个包含数据的PHP文件。 我在这里使用这段代码来附加一个包含电影标题和其他信息的PHP文件: $.ajax({ url: “/assets/filmlist.php” + ‘?’ + Math.random() * Math.random(), dataType: ‘html’, cache: false, success: function(html) { $(‘#filmlist’).html(html); } }); 这是页面: findfilmimportphp 。 这种方法在每个浏览器中都很有效,除了移动和桌面上的Safari之外我没有任何问题。 它要么不从php加载数据,要么在刷新页面之前MixItUp排序不起作用 – 有时根本没有任何事情发生。 我不知道为什么会这样,以及如何应对它。 可能导致此问题的原因是什么?

jQuery附加订单?

我正在创建一系列评论,并回复下面的评论。 我使用此代码在评论下面附加新回复。 $(document).on(‘click’, ‘.sub-reply1-send’, function() { var reply = $(‘textarea[name=comment-reply]’).val(); $(‘.sub-reply1, .sub-reply1-textarea, .sub-reply1-send’).slideUp(250).remove(); $(‘.answer’).append(“” + reply + “”); $(‘.comment-sub-reply’).slideDown(250); subreply_visible = false; }); 如果只有一个注释要回复,这样可以正常工作,但是如果有两个注释,那么让我们说Comment1和Comment2,将在Comment2下面生成Comment1。 回复Comment1将正常工作,但回复Comment2将生成Comment1中最后一个下面的回复框。 有没有办法让我这样做,以便它附加到点击它的评论? 编辑:从我拥有的HTML标记生成。 What is the significance of this section? This is not a test Test Another Test Still underneath Test This isn’t a test either, but it’s appearing under test […]

jQuery不会在页面加载上附加克隆

如果单击选项2,它会从页面加载中附加原始克隆,但每次单击该按钮时都不会重复。 1. Turn the element red… 2. Append the original black element… This is an element! $(document).ready(function () { var obj = $(“.element”).clone(true); $(“.copy”).click(function (e) { e.preventDefault(); //alert(obj); //Just to see if it still exists. $(“#container”).append(obj); }); $(“.modify”).click(function (e) { e.preventDefault(); $(“.element”).css(“color”, “#F00”); }); }); 这是我的CodePen链接http://codepen.io/anon/pen/dsvLm 有任何想法吗?

对于ie8,jquery insertAfter

var attachmentDeleteMainModal = $(‘#attachment-deletion’); var attachmentDeleteMainModalClone = attachmentDeleteMainModal.clone(); attachmentDeleteMainModalClone.attr(‘id’, ‘attachment-deletion-‘+’main’); attachmentDeleteMainModalClone.insertAfter(‘#attachment-deletion’); 这个方法将我的新选择器添加到Chrome中的DOM,但是在ie8中不起作用,这是我到目前为止测试的全部内容 append而不是insertAfter不会在任一浏览器中创建所需的选择器。 但是在ie8中它根本不会创造任何东西 这是什么解决方案? 任何洞察力都赞赏

有没有办法切换.append()jQuery方法?

我想追加另一个img来代替plus.svg。 如果你们知道以某种方式切换.append()方法的方法,那就太好了。 我想在你点击它时更改CSS,然后基本上再次更改它。 $(function(){ $(“#btw”).click(function(){ $(“#btwl”).slideToggle(300); $(this).append(“#btw::before{content: url(minus.svg);width: 16px;eight: 16px;background-size: 16px 16px;background-repeat: no-repeat;vertical-align: middle;padding-right: 10px;}”); }); });

for循环之后的多个元素的jQuery append(),而不是展平为HTML

我有一个循环: for (index = 0; index < total_groups; index += 1) { groups[index].list_item = $(list_item_snippet); // Closure to bind the index for event handling (function (new_index) { groups[index].list_item.find('.listing-group-title') .html(groups[index].Group.Name) .click(function(e){ fns.manageActiveGroup(new_index, groups); return false; }); })(index); // Append to DOM mkp.$group_listing.append(groups[index].list_item); }; 每次循环触发时我宁愿不调用append() 。 我知道我可以使用String并将标记与每个循环迭代连接mkp.$group_listing并在最后将字符串附加到mkp.$group_listing ,但是这会使对象变平并且绑定会丢失(我不依赖于ID)。 有没有办法可以将我的对象添加到数组中并将它们全部一次性地附加到底部而不会转换为HTML? 假设: $(list_item_snippet)包含一些定义列表项的HTML(并包含一个类为.listing-group-title的元素)。 groups是我的脚本中定义“组”的JSON块 封闭效果很好 编辑: 发现我可以使用以下语法追加多个元素: mkp.$group_listing.append(groups[0].list_item, groups[1].list_item […]

使用jQuery时创建有效的XHTML .append()

在这里的示例中: http : //api.jquery.com/append/它们显示直接HTML用作参数: $(‘.inner’).append(‘Test’); 但是W3的validation器会像这样反对 Line 96, column 76: document type does not allow element “p” here …ata).append(“<p class='pag 我该怎么做才能获得有效的XHTML? 编辑 – 以下是PHP编写的示例: $(‘#citations_18401-01’).html(data).append(“Result Pages: 1 2  “);

将字符串附加到tinyMCE实例

我需要将一个字符串(img标签)附加到tinyMCE编辑器实例。 我是这样做的: $(“#textboxhiddenbytinymce”).append( string ); tinyMCE.triggerSave(); 没有运气。 我想知道是否: 有一个直接的方法可以将一个任意字符串(我需要完全控制它)添加到一个tinyMCE的实例中我明白我这样做的方式是错误的,因为tinyMCE独立地工作于“原始”textarea。 非常感谢你!