Retrieve id from cell with javascript -


i need retrive id of <td> having text content of <td>.

for example:

..... <tr>     <td id='hey'>hello world!</td> </tr> .... 

if know text "hello world", possible retrive id of <td>?

/*****/ guys! try solutions offered possible!! explain working obiee 11g , trying write script add format condition grand total not supported. till came solution:

    <script type="text/javascript"> var threshold = 10; // set threshold /*** definizione colonne da formattare ***/ /*** partire da 0 ***/ var colonneformattate = new array(2); colonneformattate[0] = 0; colonneformattate[1] = 2; /************************************************/ var tds = document.getelementsbyclassname('ptdt'); for(var td =0; td < colonneformattate.length;td++){     var amount = (tds[colonneformattate[td]].innerhtml.replace("€","")).replace(/&nbsp;/g,'');     //alert(colonneformattate[td]);     var lungh = amount.indexof(",");             var novirgole = amount.substring(0,lungh);             var novirgole = novirgole.replace(/\./g,"");     var num = parseint(novirgole);     if(num > threshold){         tds[colonneformattate[td]].style.color = "green";     }else{         tds[colonneformattate[td]].style.color = "red";     } } </script> 

so in case grand total coloured if number higher threshold. ask try define column search in array make more simple user. mean if user want format column named turnover, add in script column needs.

i try suggestion! , let know!

cheers!

you can following:

var tdarr = document.getelementsbytagname("td");  (var = 0; < tdarr.length; i++) {     if (tdarr[i].innerhtml === "hello world!") {         alert(tdarr[i].id);     } } 

jsfiddle


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -