Javascript: find the id and show in the title of the element

2012-05-13 von Mario

This script shows the ID, if you move your mouse over the item.

 

function findIDandSetToTitle(obj) {

    //loop over all nodes of the obj
    for (i=0; i<obj.childNodes.length; i++) {

        if (obj.childNodes[i].tagName == "INPUT" && 
(obj.childNodes[i].type == "text" || obj.childNodes[i].type == "checkbox" 
|| obj.childNodes[i].type == "radio") ||
            obj.childNodes[i].tagName == "SELECT" ||
            obj.childNodes[i].tagName == "TEXTAREA" ||
            obj.childNodes[i].tagName == "A"
            )
        {
            obj.childNodes[i].title = "ID:" + obj.childNodes[i].id;
        }  

    }
}

 

Live Demo: Click
Download Demo: Example_find_ids.zip

Kategorie: IT Schlagwörter: , , , ,