Allow * wildcard in .removeClass()
It would be nice to be able to use the * character as a wildcard in calls to .removeClass(). For example, elem.removeClass('foo-*') would remove all classes that start with foo-. Currently, the easiest way to do this seems to be the following, which is neither elegant nor efficient: .removeClass(function (_, cl) { return cl.split(' ').filter(function (c) { return c.substr(0, "foo-".length) === "foo-"; }).join(' '); })
jQuery event listener-Continuous or Live
I have my input elements and their change events to handle some display. After loading page, When input values are changed through some other jquery functions...I do not have a way to know the values are changed. Please note that I can not change or do anything with that other jquery function which changes my input values. It is not in my control. Can we have something in jQuery API which continuously keep checking or listening any changes happened to the html elements through external/internal uncontrollable
Proposal of an extension to jQuery core for async loading and module definition.
Hello friendly jQuery people! Please excuse this rather long mail. I'm writing on it and the docs for the better part of this day. (And excuse the word "mail" and the formating in the following. I thought there was a mailing list to post it to. Now I'm feeling a little old school while pasting it in here ;) Quicktip: There is documentation and code at https://github.com/ScheintodX/jqinit.js if you which to skip my writing and just have a peek. I'm the author of jqinit.js and would like to propose
query by id - ignore context
When selecting elements jQuery provides an optional 2nd argument (context) which limits the search to a specific node. Adding this argument usually speeds up queries, but when the query is by id adding the context actually siginificantly slows down the query. As a test, go here: http://jquery.com/ and run this script in Firebug: console.time("1"); for(var i=0; i<2000; i++) { $("#jq-intro"); } console.timeEnd("1"); console.time("2"); for(var i=0; i<2000; i++) { $("#jq-content"); $("#jq-intro"); }
about jQuery.parseJSON
when I see the codes below: return window.JSON && window.JSON.parse ? window.JSON.parse( data ) : (new Function("return " + data))(); I think the the (new Function("return " + data))(); is slower than use eval directly, it may be improved this way: ( eval( "["+data+"]" ) ) [0]
about jQuery.makeArray
makeArray: function( array, results ) { var ret = results || []; if ( array != null ) { // The window, strings (and functions) also have 'length' // The extra typeof function check is to prevent crashes // in Safari 2 (See: #3039) if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) { push.call( ret, array ); } else { jQuery.merge( ret, array ); } } return ret; }, when the argument arr is actually an array, it
A new type of .live() event
Hello. I want propose a new "event" to .live(). See this case: I'm using AJAX to load HTML, and for all .roundedBox I need apply in ajax.success: $('.roundedBox').css({borderRadius: 5}); I suggest any more intelligent: $('.roundedBox').live('all', function(){ $(this).css({borderRadius: 5}); }); // Obs: the event "all" is only a bad-suggestion, is only for example Or be: to ALL new .roundedBox (indepentends if it is from AJAX HTML content or not), will be applied this event-method. Currently is
Use JS hack-reference to improve speed
Hello! I found on "wtfjs.com" a method to do JS-reference, as the & in php. MAYBE this can improve JS. This is the basic idea: function x(object){ // I need re-use object on another method reUse(object); // I suppose that JS copy object to reUse function console.log(object); // Here is different, JS will pass a reference of object, but it's strange... reUseAgain(arguments); console.log(object); } function reUse(object){ object = 1; } function reUseAgain(object){ object[0] = 1;
creating elements - arguments
Hi, I might be missing something, and apologies in advance if I am, but it seems at the moment to create elements the syntax is something like $("<tagname>", props); I was wondering if it was possible to change it to something like $("<tagname>", content, props) content being a string ... or possibly even another jquery object so that it would be possible to do the following: $("<p>", "Hello World") or $("<div>", $("<a>", "jQuery").attr("href", "http://www.jquery.com/") ).addClass("something");