Dojo getting element attribute ID from node -
All the following code searches are an internal text of "pre: bob" for a span and one element goes back (Which will be Input element) JS: to do rather than what it is I need it: class = "dijitReset dijitTextBox notDojoDndHandle testClass" It is still this: < P> class = "DijitReset dijitTextBox notDojoDandHandle" The question is: How can I get it from the id node of that input? (Has been found) since I need the id to work .addClass To get things listed here: To do this, wrap your code inside You are confirming that the internal HTML A Or, even better, If you have done so, your code should work, as you can see in the following Bella:
& lt; Input Dojoattachpoint = "text box, focusNode, _aroundNode" dojoattachevent = "onBlur :. onBlur, onFocus: onFocus, onkeyup: onkeyup" id = "2c6af1dc-80cb-44f2-864d-1fb00216895dF_SingleLine- widget" Name = "" class = "DijitReset dijitTextBox notDojoDndHandle "type =" text "tabindex =" 0 "aria- label =" text "width =" auto "value =" "aria-describedby =" 2c6af1dc-80cb-44f2-864d-1fb00216895dF_SingleLine- widget-placeholder "style = "Max-width: 2.5em; width: 90%;" & Gt; & Lt; span class = "dijitPlaceHolder dijitInputField" id = "2c6af1dc-80cb-44f2-864d-1fb00216895dF_SingleLine- widget-placeholder" style = "max-width: 2.5em; width: 90%;" & Gt; Formerly: Bob & lt; / Span & gt;
dojo.query ( "span.dijitPlaceHolder.dijitInputField") foreach (function (node index arrival) {if. (Node.jener html === 'ex: bob') {var foundIt = dojo.query (node) .prev (); dojo.addClass (found this, "testclass");}}); Make sure the DOM loads Is happening
dojo.addOnLoad () function, for example:
dojo.addOnLoad (function () {// your code}); Trim your text
"Ex: Bob" is, however, currently your Internal HTML also has some new lines and possibly some tabs (because you put it on a new line). To resolve this, you should trim your content before comparing it, for example:
if (node creator.HTML.trim () === 'ex: Bob') {// your code}
dojo.query a returns dood.NodeList dojo.query module returns a dojo.NodeList , which is compatible with dojo.addClass () function That's either ID or A-DOM node. dojo.NodeList is actually an array of DOM nodes, so you can write something like:
var foundIt = dojo.query (node) .prev (); Dojo.addClass (found it [0], "test class"); // Return to the element at index 0 dojo.NodeList is also a function that is called addClass () This list is applied to, for example:
dojo.query (node) .prev (). AddClass ("testclass"); // Less and easy Be sure to include the appropriate module
dojo.NodeList :: prev () requires functionality Dojo.NodeList-traverse is to be loaded, while dojo.NodeList :: addClass () to load dojo.NodeList-dom functionality essential for. I do not know exactly what module list you are in, but I started with Dojo myself 1.7 and I have a habit of listing all the modules, for example:
dojo.require (" dojo.query "); Dojo.require ("dojo.NodeList-cross"); Dojo.require ("dojo.NodeList-DOM");
Comments
Post a Comment