You're obviously way more clued up about Javascript than me, so I'm not even going to try & understand your code! But your question reminds me of one I had a few days ago, so I thought I'd offer it you in case it helps: http://groups.google.com/group/jquery-en/browse_frm/thread/1e5bcd25972c8153#
If it doesn't, you're no worse off ;) Cherry On Apr 24, 5:16 pm, tronen <[EMAIL PROTECTED]> wrote: > Hi, I am new to jQuery and is curious if this code can be shortened > down? It feels like it can, but I couldn't find any way to use jQuery > selectors if I have a specific reference to a object. > > What I want to do is to find the element to the parent of "el" that > the id starts with linecolorbox. I know how to do it if I want to find > ALL the ones that id start with linecolorbox, but not if I want to > start with a specific element as reference (el.parentNode). > > jQ('.linecolor').each( > function() { > try { > var el = this; > if(el.value.match(/^f{6}$/i)) { > el.value = ''; > } > var nodes = el.parentNode.childNodes; > for(var i=0; i<nodes.length; i++) { > for(var j=0; > j<nodes[i].childNodes.length; j++) { > > if(nodes[i].childNodes[j].id) { > > if(nodes[i].childNodes[j].id.match(/^linecolorbox/)) { > var > colorbox = nodes[i].childNodes[j]; > > if(el.value.match(/^[0-9a-f]{6}$/i)) { > > colorbox.innerHTML = ' '; > } > else { > > colorbox.innerHTML = ' X '; > } > } > } > } > } > } catch(e) { > alert(e.message); > } > } > );