Monday, 15 July 2013

javascript - dojo get parent of present node in foreach -


In jQuery, I used the parent () function for the immediate parent of any element,

$ (this). Parent ();

The same I want in the dojo is my loop this way. / Var / url = dojo.attr (node, "href"); // I want to get the node's parent, which will be completely different for each iteration)};

Someone gave me a hint, I tried to use the parent. I am trying to add the parent to the node like this

  dojo.place ("& lt; span style = 'color: green' & gt; url & lt; / Span & gt; ", query (node) .parent ()," last ");  

I'm getting this error in firebug

type error: _365.appendChild function is not

Regards

Adam

Here are some problems:

  1. dojo.place () or dojo / dom-build :: location () dojo / nodeList for use by API dojo / Query . In place of such use modules such as dojo / nodeList-manipulate or dojo / nodeList-dom . Since you are a jQuery user, I recommend using the dojo / nodeList-manipulate as it does a mix of jQuery APIs.
  2. To retrieve the origin of a DOM node, you actually have the parent () method, but that part of the API is available only when you Dojo / nodeList-traverse .

An example using this feedback:

  is required (["dojo / query "Dojo / Nodist-Trowers", "Dojo / Node List-Heripple", "Dojo / domReady!"], Function (query) {query (". EntryURL"). ForEach (function (node, index, ARM) { Query (node) .parent ("& lt; span style = 'color: green' & gt; url & lt; / span & gt;);});});  

JSFiddle:


No comments:

Post a Comment