|
I use MooTools, and I need to find the element which has both classes "a" and "b" (the innermost div in my example below).
The HTML structure is:
<div class="a"> <div class="otherclass"> <div class="b"></div> </div> </...
Started by Nir on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
What about
$$('div.a div.b')
or
$$("div.a").getElements("div.b");
var divsB = $$("div.a div.b");
http://mootools.net/shell/jfnWK/ - selects the first one but not the second as it's not a child of a div.a .
|
|
I want to write some javascript classes which extend DOM nodes (so that I can then insert instances of my class directly into the DOM), but am having difficulty finding out which class/prototype I should inherit from.
eg
function myExtendedElement() {...
Started by wheresrhys on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The....
At least, it enables me to access the extended object properties via the DOM element from DOM element, you need to have access to that element's prototype.
You can simply add new functions to the DOM prototypes, eg that works...
|
|
In Javascript, you can extend existing classes by using its prototype object:
String.prototype.getFirstLetter = function() { return this[0]; };
Is it possible to use this method to extend DOM elements?
Started by nickf on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Plus re-extending every new.
However, this does (by "anything" I mean native DOM objects) - that will only lead to bad things.
() { return this.id; };
you can extend the DOM by using the Element's prototype.
|
Ask your Facebook Friends
|
In javascript, what are the pro's and con's of encoding an onclick event in the DOM and in the HTML itself?
Which, if either, is better than the other and why?
Started by johnnietheblack on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
It is even better to use proper DOM events ( addEventListener and attachEvent ) rather than.
Attaching events to an CSS-style ID (or classes), as Jquery does so says.
Everything down all at once.
|
|
Can I test my client side GWT code without GWTTestCase? I've heard somewhere (I think it was one of the Google IO 2009 conferences) that they were successfully testing their code with a fake DOM, in the JVM and not in Javascript with the DOM. That would...
Started by Eugen on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
By doing this, you, without the need for a browser... .
Any code that requires the DOM should go in your View classes/Presenter pattern and abstract away all the DOM-accessing code to the 'View' portion.
The Model-View-Presenter pattern.
|
|
When using $("#xxx") I guess under the hoods jQuery uses getElementById .
What about $(".xxx") does it scan the whole DOM every time?
Started by flybywire on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
JQuery attempts to use the fastest selection://www.componenthouse.com/article-19
http:....
Many browsers do not support getElementsByClassName as a native DOM function, so jQuery has to do the work itself by checking each element's classes.
|
|
I'm trying to modify the class of an element if an ajax call based on that element is successful
<script type='text/javascript'> $("#a.toggle").click(function(e){ $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function...
Started by Issac Kelly on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Example:
$("#a.toggle").click(function(e) { var target = $(this); $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function(data,text) { if(data.error=='') { if(target.hasClass('class1')) {... .
You can just store it in a variable.
|
|
Hey all,
I was just wondering if there is a clean implementation to getting elements before appending them to the DOM.
Example (w/ jQuery):
var html = "<div class = 'test'><div class = 'innertest'>Hello!</div></div>"; var innerDiv...
Started by Matt on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Do any sort of editing....
I would like.
Looked at DOM DocumentFragments ?
As far As i understood you want to edit a certain piece of DOM to your satisfaction before you display it , like you Manipulate a DOM thats currently in Display.
|
|
I am a pretty good programmer(IMO only, of course. Know Python, Java well. Tried my hands at Lisp, Ruby, Haskell). I also know how to use Jquery reasonable well, so I know Dom manipulation.
I want a recommendation on a Javascript book, which teaches the...
Started by uswaretech on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Some of the examples do involve the DOM, but they really give a feel for the flexibility of the core.
By showing a number of approaches for simulating classes, classical inheritance, private members, etc.
|
|
Is it possible to have some sort of Id scoping when manipulating DOM with JS?
I use jQuery as my JS framework.
For example:
Is there any mechanism that would allow to select someDiv children of first or someDiv children of second, or do all ids on the...
Started by jd on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The id attribute can be used by a JavaScript (via the HTML DOM) or by
CSS to make changes or style.
|