Tag: jQuery

在jQuery的wait()或sleep()函数?

我想添加一个类,等待2秒钟,并添加另一个类。 .addClass("load").wait(2sec).addClass("done"); 有什么办法吗?

如何用jQuery格式化电话号码

我目前正在显示电话号码,如2124771000 。 但是,我需要将数字格式化为更易读的格式,例如: 212-477-1000 。 这是我目前的HTML : <p class="phone">2124771000</p>

无法在jQuery.ajax中将content-type设置为“application / json”

当我有这个代码 $.ajax({ type: 'POST', //contentType: "application/json", url: 'http://localhost:16329/Hello', data: { name: 'norm' }, dataType: 'json' }); 在提琴手我可以看到下面的原始请求 POST http://localhost:16329/Hello HTTP/1.1 Host: localhost:16329 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Referer: http://localhost:14693/WebSite1/index.html Content-Length: 9 Origin: http://localhost:14693 Pragma: no-cache Cache-Control: […]

有没有办法放大D3力布局图?

D3 在这里有一个强制定向布局。 有没有添加缩放到这个图表的方法? 目前,我能够捕捉鼠标滚轮事件,但是我不确定如何编写重绘function本身。 有什么build议么? var vis = d3.select("#graph") .append("svg:svg") .call(d3.behavior.zoom().on("zoom", redraw)) // <– redraw function .attr("width", w) .attr("height", h);

jQuery的:如何得到一个父母的特定孩子?

为了给出一个简单的例子,我在页面上重复了下面的块(它是dynamic生成的): <div class="box"> <div class="something1"></div> <div class="something2"> <a class="mylink">My link</a> </div> </div> 点击后,我可以通过以下链接进入链接的父级: $(".mylink").click(function() { $(this).parents(".box").fadeOut("fast"); }); 但是…我需要去那个特殊的父母的<div class="something1"> 。 基本上,有人可以告诉我如何参考一个更高级别的兄弟姐妹,而不能直接引用它? 我们称之为大哥。 直接引用大哥的类名会导致页面上该元素的每个实例都淡出 – 这不是所期望的效果。 我试过了: parents(".box .something1") … no luck. parents(".box > .something1") … no luck. siblings() … no luck. 任何人? 谢谢。

用jQueryselect最后5个元素

是否有可能select元素的最后5个子div?

jQuery:如何find第一个可见的input/select/文本区域排除button?

我试过了 $(":input:not(input[type=button],input[type=submit],button):visible:first") 但是没有find任何东西。 我的错误是什么? UPD:我执行$(document).load() <script type="text/javascript"> $(window).load(function () { var aspForm = $("form#aspnetForm"); var firstInput = $(":input:not(input[type=button],input[type=submit],button):visible:first", aspForm); firstInput.focus(); }); </script> 并在debugging中,我可以看到firstInput是空的。 UPD2:我在ASP.NET页面下运行Sharepoint。 我发现迄今为止,对于某些元素,它确实find了它们(对于固定的),而对于一些则没有。 🙁

如何使用jQueryselect第一个父DIV?

var classes = $(this).attr('class').split(' '); // this gets the current element classes var classes = $(this).parent().attr('class').split(' '); // this gets the parent classes. 在上述情况下的父母是一个ankor。 如果我想获得$(this)的第一个父DIV,代码将是什么样的? var classes = $(this).div:parent().attr('class').split(' '); // just a quick try. *基本上我想获得$(this)的第一个父DIV的类。 谢谢

为什么我们在jQuery中使用“({})”?

为什么我们使用({ }) ? 是代表吗? 这个语法是什么意思? 我们用什么包装呢? 例如: $.ajaxSetup ({ // <– THIS error: fError, compelete: fComp, success: fSucc }); // <– AND THIS

强制页面滚动位置在页面刷新页面顶部

我正在build立一个网站,我与div发布。 在滚动到位置X后刷新页面时,页面将以滚动位置加载为X. 我如何强制页面滚动到页面刷新顶部? 我能想到的是一些JS或jQuery作为页面的onLoad()函数运行,以将页面滚动到顶部。 但我不知道我该怎么做。 一个更好的select是,如果有一些属性或东西的页面加载其默认的滚动位置(即在顶部),这将有点像页面加载 ,而不是页面刷新 。