Tag: jquery selectors

如何在使用JQuery时停止jsdom自动sorting的href结果?

这个脚本使用jsdom和jquery来获取标签的href属性的值。 出于某种原因,它出来完全合格,相对于我正在运行脚本的path。我怎样才能得到只有 href值,不完全合格? var currentDoc = jsdom.jsdom('<html><head><title>href test</title></head><body><p><a href="test.html">Test</a></p></body></html>';, null, {}); var window = currentDoc.createWindow(); jsdom.jQueryify(window, 'jquery-1.4.2.min.js' , function() { console.log(window.$('a')[0]['href']); }); (代码片段也在https://gist.github.com/2355968 )

jQuery,为触发事件的元素findselect器

我正在开发一个相当轻量级的实时应用程序。 我们正在使用jQuery的事件系统在应用程序中的模块之间进行对话。 因此,在DOM中进行更改的所有内容都必须通过事件来实现。 这些事件被一个客户端的socket.io实现捕获,它要求nodejs socket.io服务器把事件广播给所有其他客户端。 我的问题:有没有办法找出事件触发的select器? 所以,如果我打电话 $("tag.class").trigger("myevent"); 我可以做某事 $(document).on("myevent", function() { console.log(this.selector) }); 它会打印“tag.class” 这很有趣,因为知道用户在select时触发了某个事件,而不是某个元素上的某个事件,这些事件之后可能显得非常随机,这将是有趣的。 我已经读过这个问题,但我希望能够得到在应用程序中触发的所有事件的select器。 感谢您的时间 :)

如何在Node.js中使用JQueryselect器

我试图从硬盘中的HTML文件中提取电子邮件信息。 如果我在firefox中加载文件并运行jQuerify书签,我可以成功地使用下面的select器/函数 window.jQuery("a.iEmail").each(function(el) { console.log(window.jQuery(this).attr('href')) }); 但是在Node.js中使用这个不起作用 var document = require("jsdom").jsdom(), script = document.createElement("script"), fs = require('fs'); fs.readFile('file_1.html', 'utf-8', function(err, data){ if (err) { throw err; } // This output the document //console.log(data) var window = document.createWindow(data); script.src = 'http://code.jquery.com/jquery-1.4.2.js'; script.onload = function() { console.log(window.jQuery.fn.jquery); // outputs: 1.4.2 //console.log(window.jQuery); /* * This line works if […]