Skip to content Skip to sidebar Skip to footer

Javascript Find Node Without Id

Due to a limitation of the Javascript library I'm using, I can't assign an id to a
. Unfortunately, I don't know how to attach a Tooltip object from Tipped, a Javascript

Solution 1:

Tipped actually accepts any CSS selector as an argument. If the class is unique, you could target it that way:

Tipped.create('.dhx_toolbar_btn', 'some tooltip text');

Or if the class isn't unique, you could try target it via the tree structure. Made up example:

Tipped.create('.header .sidebar .dhx_toolbar_btn', 'some tooltip text');

I noticed in your html that the buttons have empty title attributes (or maybe your inspector just added them). If you can set the title attribute for the buttons Tipped will pick it up automatically. Example:

<div class="dhx_toolbar_btn" title="test title">

You would then only have to use:

Tipped.create('.dhx_toolbar_btn');

And Tipped will automatically pick up the title and use it.


Solution 2:

This is what I was trying to have explained:

var Obj         = document.getElementsByClassName("classname");
var ObjChildren = Obj[0].getElementsByTagName("tag")
var searchText = "string";

for (var i = 0; i < ObjChildren.length; i < i++) {
    if (ObjChildren[i].innerHTML == searchText) {
        console.log(ObjChildren[i].innerHTML);
    }
}

Post a Comment for "Javascript Find Node Without Id"