Tag: 函数

.fadeTo无法延迟淡出

试图将淡入淡出500延迟到1000,但是当我改变.fadeTo(‘500’, 1); to .fadeTo(‘1000’, 1); 褪色不是延迟。 相同的时间,500到1000之间没有区别。 jQuery的: $(“.more-post”).one(“click”, function () { $(‘.bottom-post’).addClass(‘show-more’).fadeTo(‘500’, 0); setTimeout(function(){ $(‘.bottom-post’).addClass(‘show-more’).fadeTo(‘500’, 1); },4000); }); 这个Jquery很快就会消失,所以如何将延迟淡出更多.fadeTo(‘1000’, 1); 。 想要褪色更慢。 谢谢。

Jquery nextUntil()替代

我有以下代码,这是尼克在之前的一个问题中提供的 ,它就像一个梦想。 我在想什么 “我正在尝试生成一个jquery脚本,以便使用类顶部的表格中的所有tr元素进行拼接,并且当使用类bt点击下面的所有tr时,使用类顶部的一个tr,直到有另一个tr类顶部将slideToggle。” 但是我确实必须在某些表中的top和bt类之间添加一个额外的行,这会破坏这些表中的jquery。 我想知道是否有任何修改,我不需要更改表中的代码,它仍然适用于所有应用的网页上的所有表。 JS Bin $(“tr.top”).click(function () { $(this).nextUntil(‘tr:not(.bt)’).animate({ opacity: “toggle” }); }); Click here to collapse the next tr with class bt but no other top row 1 top row 1 This is not ment to collapse when the tr at the top is clicked bt row 1 bt row 1 […]

jQuery .toggle()与第二个函数没有按预期工作?

我正在尝试创建一个按钮来显示/隐藏它下方的div,一切正常,我只是在最后一点挣扎! 我需要区分它是一个节目还是隐藏动作所以我可以将变量传递到别处,这就是我所拥有的…… $(this).find(‘.hide-close’).click( function() { $(this).siblings(‘.dragbox-content’).toggle(function() { alert($(this).parent().attr(“id”) + ‘ Show’); },function() { alert($(this).parent().attr(“id”) + ‘ Hide’); } ); }) .end() }); 如果使用以下代码,取出toggle()中的第二个函数,它有效吗?! 但后来我没有显示/隐藏变量。 $(this).find(‘.hide-close’).click( function() { $(this).siblings(‘.dragbox-content’).toggle(function() { alert($(this).parent().attr(“id”) + ‘ Show’); } ); }) .end() }); 在此先感谢您的帮助,希望这是我看不到的非常简单! 🙂

覆盖Javascript函数的参数对象

如果我有以下内容: // Clean input. $.each(arguments, function(index, value) { arguments[index] = value.replace(/[\W\s]+/g, ”).toLowerCase(); }); 这会是一件坏事吗? 我没有进一步使用函数中未清理的参数,如果不创建一个无用的arguments副本只是为了使用它们会很好,但这样做有什么负面影响吗? 理想情况下我会这样做,但我猜这会遇到问题,因为arguments不是一个数组: arguments = $.map(arguments, function(value) { return value.replace(/[\W\s]+/g, ”).toLowerCase(); }); 感谢您的任何意见。 编辑:我刚刚意识到这两个现在都在他们自己的函数中,所以arguments对象已经改变了。 没有创建不必要的变量的任何方法吗?

计算具有特定类的元素数量,然后添加一个对其进行编号的ID

我对此非常陌生,只想把其他post的片段拼凑起来。 我不确定如何计算页面上的元素数量,然后添加一个类来区分它们的数字。 $(document).ready(function(){ $(‘.item’).each(function (e) { $(this).addClass(‘count’ + e); }); }); 输出到:

并非所有内容都显示在弹出窗口内部

我有一个弹出插件。 每当我点击链接时,element_to_pop_up DIV中的内容都会写在弹出窗口中。 但是我添加了一个没有出现在弹出窗口中的function,它在主页面外显示出来。 为什么会这样? 我猜这些点让这个函数得到回应,但它们不在弹出DIV的元素之外。 怎么克服它? function writecomments($photoid){ echo $photoid; } echo ” “.writecomments($photoid).” “; } 我正在使用bpopup插件 http://dinbror.dk/blog/bPopup/ 源代码: writecomments(302)

等待换行并计算

我的function看起来像那样 function count() { var value = ids.val(); return (value == ”) ? 0 : value.split(/\r\n|\r|\n/).filter($.trim).map($.trim).length; } 有一个问题。 我有autopostfunction,每隔1秒检查一次count() 。 if(count() === 10){ ajaxpost! } 条形码阅读器逐个输入数字:每次扫描后添加新行。 如何修改此函数以等待新行和计数? 对于前者 8 函数必须返回0(当前在键入任何值后直接返回1) 8 function必须返回1

jQuery插件返回this.each并为每个对象添加函数属性?

是否有可能创建一个jQuery插件,返回this.each以进行多次匹配,从而允许我为每个循环中的每个对象添加一个函数属性? 我想稍后直接从​​该对象调用此函数。 例如,这是我正在尝试做的简化版本: (function ( $ ) { $.fn.roflcopter = function( options ) { return this.each(function() { $(this).addClass(‘lol’); $(this).getMyValue = function(e){ return returnMyFilteredValue($(this)); } }); function returnMyFilteredValue(elem){ return $(elem).val().replace(“cat”, “dog”); } }; }( jQuery )); 然后我想在document.ready函数中调用这个: $(“input.coolStuff”).roflcopter(); var value = $(“input.coolStuff”).first().getMyValue(); 这可能吗? 我收到一条错误,指出getMyValue不是一个函数。

这个模糊function有什么问题?

我有这个模糊function,如下所示,并在第一次它不检查和文本改变第二次它工作 function ShowAvailability() { var userName = $(“#”); $(“#”).blur(function () { userName = $(this).val(); if (userName.length < 5) { $("#mesg")[0].innerHTML = ""; } else { $.ajax({ type: "POST", url: "Default.aspx/CheckUserName", data: '{userName: "' + $("#”)[0].value + ‘” }’, contentType: “application/json; charset=utf-8”, dataType: “json”, success: OnSuccess, failure: function (response) { alert(response); } }); } }); } […]

localStorage压缩? – jquery

我有一个function,可以在点击时将div的样式保存并清除到localStorage: var originalAttributes = $(‘.aaa’).attr(‘style’); $(‘.aaa’).each(function(){ var d = $(this), id = d.attr(‘id’), storedStyle = window.localStorage.getItem(‘aaaStyle’ + id); if (storedStyle != undefined){ //style stored d.attr(‘style’, storedStyle); } }); //mouse event functions for class=”aaa” $(‘#save’).click(function () { $(‘.aaa’).each(function(){ var d = $(this), id = d.attr(‘id’), style = d.attr(‘style’); if (style != originalAttributes){ //style changed //$.cookie(‘aaaStyle’ + […]