Jump to content

Html , Javascript Experts Raavali


Recommended Posts

Posted

 

yep chesanu

 

 

$(document).ready(function () {
$("#Table2.evenodd tr:not([th]):odd").addClass("odd");
    $("#Table2.evenodd tr:not([th]):even").addClass("even");
});
 
 
here Table2 is ID of the table
 
and i removed # b4Table2 and tried but no use

 

oka pani cheyyi 

 

1st get the id like this  

var table2 = document.getElementById('Table2'); then use table2 in u r function
Posted

dynamic ga create aina elements jquery ki dorakav direct ga..... you have to use

 

$(document).find("#Table2.evenodd tr:not([th]):odd").addClass("odd");  ---- try that it should work

 

 

 

Posted

thanks every one

 

some how jQuery pani cheyyaledu

i did this way

 

function alternate(id) {
 
          if (document.getElementsByTagName) {
                var table = document.getElementById(id);
                var rows = table.getElementsByTagName("tr");
                for (i = 1; i < rows.length; i++) {
                       if (i % 2 == 0) {
                                rows[i].className = "even";
                        } else {
                                  rows[i].className = "odd";
                       }
              }
       }
}
 
after that 
 
<body onload="alternate('Table2')">
 
and this 

<style> 
  .odd{background-color: white;} 
  .even{background-color: gray;} 
</style>
 
this one worked 
 
Posted

 

thanks every one

 

some how jQuery pani cheyyaledu

i did this way

 

function alternate(id){ 
 
 if(document.getElementsByTagName){  
 
   var table = document.getElementById(id);   
 
   var rows = table.getElementsByTagName("tr");   
 
   for(i = 0; i < rows.length; i++){           
 
 //manipulate rows 
 
     if(i % 2 == 0){ 
 
       rows[i].className = "even"; 
 
     }else{ 
 
       rows[i].className = "odd"; 
 
     }       
 
   } 
 
 } 
 
}
 
after that 
 
 
<body onload="alternate('Table2')">
 
and this 
 

<style> 
 
  .odd{background-color: white;} 
 
  .even{background-color: gray;} 
 
</style>
 
this one worked 

 

S%Hi

×
×
  • Create New...