I am new to javascript and jQuery.
i just want to know that is there any way create something different ,say structured dom language ?
in jQuery to select all div
var divs = $("div");
i want to know the possibility of something like this
var SDL = new SDL();
var div = SDL.query("select div from document"); //or something like that ..
or to select a div with ID
var div = SDL.query("select div from document where id='divID'");
looking mad right ?
i am sure i will not care about the downvotes for the question , but i need to know why this is not good ? or why its is not posible ?
Please say something on this …
Thank you.
It’s not good because it’s pointless to implement or use. It would make the jQuery library much larger than it needs to be, and CSS selectors are clear enough anyway, as well as being far more concise.
It is possible, but what you’re describing is actually pretty close to CSS selectors, but with a couple of extraneous words thrown in with some formatting changes.
In your “SDL” selector, it would simply be replaced by:
Why go through the trouble of writing a whole sentence to do the same thing? There may be a third party SQL-like selector library, in the same way Sizzle is a CSS selector library, however I’ve never heard or seen of one personally.
An SDL would also be much slower than using CSS-based selectors, as the string is more complex and has more garbage in it than a CSS selector string. More importantly, however, you wouldn’t get the native speedups that
querySelectorAll()et al give when used natively.