Tag: javascript

jquery datepicker不能动态创建html

我正在用内部控件动态创建几个div。 其中两个控件应该是日期选择器。 但由于某种原因,它们没有显示(仅显示输入文本)如果我创建静态html,它会起作用,但是当我使用动态html时则不行。 这是我用来生成HTML的代码(我可以看到div) var ShowContainerDiv = document.createElement(‘DIV’); var btnShowDiv = document.createElement(‘DIV’); btnShowDiv.id = ‘btnShowDiv ‘; btnShowDiv.title = ‘Change’; btnShowDiv.index = 120; var lblShow = document.createElement(‘label’) lblShow.htmlFor = “btnShowDiv”; lblShow.appendChild(document.createTextNode(‘Show’)); btnShowDiv.appendChild(lblShow ); btnShowDiv.onclick = function () { dropdown.style.visibility = “visible”; }; var dropdown = document.createElement(‘DIV’); dropdown.style.backgroundColor = ‘white’; dropdown.style.borderStyle = ‘solid’; dropdown.style.borderWidth = ‘2px’; dropdown.style.cursor […]

jQuery / Javascript多个数组合

我一直试图找到解决方案,但无济于事。 我想要实现的目标是能够找到多个列表的所有独特组合。 所以,假设我有3个复选框列表(但这是现实应用程序中的未知数字),颜色,大小,包大小。 列表中的项目将是unqiue。 [0] => [‘blue’, ‘green’] [1] => [‘small’, ‘medium’, ‘large’] [2] => [‘Pack Of 6’, ‘Pack Of 8’] 我想要“ 蓝色,小,6件装 ”,“ 蓝色,中号,6件装 ”,“ 蓝色,大号,6件装 ”,“ 蓝色,小号,8件装 ”,“ 蓝色,中号,包装8 “等。订购并不重要,但将其逻辑分组会很好。 我已经使用jQuery将列表拉入数组: options = []; jQuery(‘.option-types’).each(function(){ opts = []; jQuery(‘input:checked’, this).each(function(){ opts.push(jQuery(this).next().text()); }); options.push(opts) }); 如果有一个递归的function路径来回答这个是理想的,就像我说的那样,列表的数量可以是任何东西,以及列表的内容。 希望你们和女孩们可以提供帮助,这是我的头脑。 干杯 – 丹

setTimeout延迟不起作用

我试图绕着setTimeout包围我,但我无法让它正常工作。 我在这里建立了一个例子: http : //jsfiddle.net/timkl/Fca2n/ 我希望在单击一个锚点后对文本进行倒计时 – 但我的setTimeout似乎同时触发,即使我已将延迟设置为1秒。 这是我的HTML: Click me! 这是我的JS: $(document).ready(function() { function foo(){ writeNumber = $(“#target”); setTimeout(writeNumber.html(“1”),1000); setTimeout(writeNumber.html(“2”),1000); setTimeout(writeNumber.html(“3”),1000); }; $(‘a’).click(function() { foo(); }); }); 任何关于我可能做错的提示都非常感谢:)

长轮询锁定其他AJAX调用

我希望进行长时间轮询以将一些数据“推送”到客户端,并且我还与长轮询并行地向服务器进行其他无关的AJAX调用。 在长轮询收到响应(来自响应或超时)之前,我的其他AJAX调用似乎无法完成。 当我单步执行Javascript时,似乎第二个AJAX请求是在适当的时间发送的,但是在长轮询请求得到响应之前没有收到响应。 知道发生了什么事吗? 以下是长轮询部分的代码: 服务器端: function getPlaylistTracksIfChanged($playlist_id, $numClientTracks) { $reportChange = false; for($i = 0; $i PlaylistTrack->find(‘count’, array( ‘conditions’ => array(‘playlist_id’ => $playlist_id) ) ); if($numClientTracks != $numServerTracks) { $reportChange = true; break; } sleep(3); } if($reportChange) { $playlist_tracks = $this->PlaylistTrack->find(‘all’, array( ‘conditions’ => array(‘playlist_id’ => $playlist_id), ‘order’ => array(‘PlaylistTrack.position’) ) ); $this->set(‘playlist_tracks’, $playlist_tracks); […]

在jQuery中连续滚动包含图像的水平滚动条?

我想做这样的事情: http : //javascript.about.com/library/blcmarquee1.htm 我引用的脚本似乎有点滞后(过时?),所以我想知道是否有人知道更好的解决方案。 (jQuery解决方案欢迎。)

如何向JqGrid添加/编辑表单添加自定义按钮?

是否可以将自定义按钮添加到JqGrid添加/编辑表单? 我想要一个“Save and New”按钮,一个显示“Save and Close”,一个显示“Cancel”的按钮,而不仅仅是提交和取消。 是否有可能实现这一目标?

IE 7中的Javascript Date函数问题,返回NaN

我有一个Twitter提要,我创建了一个新的日期对象,所以我可以根据自己的喜好格式化日期。 var created = new Date(this.created_at)在firefox和chrome中工作,但在IE7中不起作用。 我似乎无法通过new Date()函数传递日期。 它只返回undefined和NaN。 这是代码。 如果您尝试测试它,请不要忘记包含jquery。 谢谢。 Twitter Test $(function(){ $.getJSON(“http://twitter.com/statuses/user_timeline/google.json?count=1&callback=?”, function(data){ $.each(data, function(){ var created = new Date(this.created_at) $(“”).append(“Unformatted: ” + this.created_at + “Formatted: ” + created + “”).appendTo(“body”) }); }) })

jQuery – 有以类开头的类

什么是获得所有具有任何以input开头的类的div的最佳方法? 换句话说, a和b应该从下面的内容返回,而不是c 。 令人惊讶地接受的表面方式是做$(“div[class^=’input’]”); 但当然错过了b 。 当然还有$(“div[class*=’input’]”); 会对c产生误报。 我能想到的最好的就是这种怪异 function getAllInputDivs() { return $(“div”).filter(function (i, currentDiv) { return $.grep($(currentDiv).attr(“class”).split(” “), function (val) { return val.substr(0, “input”.length) === “input”; }).length > 0; }); } 有更干净的方式吗? 这是上面的工作小提琴

在javascript中使用API​​ v3检索Google日历活动

去年我使用http://gdata-javascript-client.googlecode.com/svn/trunk/samples/calendar/simple_sample/simple_sample.html中的代码从公共Google日历的“现在”检索所有事件,然后在网页中显示结果。 我修改了该代码以满足我的需求(请参阅下面的代码)。 现在,使用API​​ v3,代码不再起作用,我无法理解代码的哪些行已被弃用以及如何更新它们。 可以请有人帮我这个代码吗? 非常感谢 :-) /* Loads the Google data JavaScript client library */ google.load(“gdata”, “2.x”); function init() { // init the Google data JS client library with an error handler google.gdata.client.init(handleGDError); // load the code.google.com calendar loadMyCalendar(); } /** * Loads the Google Event Calendar */ function loadMyCalendar() { loadCalendarByAddress(‘MY_ADDRESS@gmail.com’); /* address […]

使用Javascript / jQuery在当前窗口后面打开一个窗口

我想在点击时打开一个窗口,但是我想在当前窗口后面打开它,或者当新窗口打开时它应该最小化。 我做了一个function,但实际上没有用。 Untitled Document function wn(){ var mm=window.open(‘http://www.google.com’,’newwindow’,’width=200, height=200′, “_blank”); } click