jQuery finden Sie td mit Klasse-name und ändern Sie den text basierend auf dem Wert

Habe ich Tabelle und ich möchte die filter alle td-Werte basiert auf Kategorie Namen, und dann wenn der td hält einen bestimmten text ersetzen Sie es mit neuen text. unten ist mein Aktueller code. seine nicht ordnungsgemäß funktioniert und die Aktualisierung aller td ' s .
bitte um Rat, wie Sie Vorgehen.

html

 <td class="actionclass">' . $page->action . '</td>

jquery

$("tbody").find("tr").each(function() { //get all rows in table
    var ratingTdText = $(this).find('td.actionclass').text();
    if ((ratingTdText == "saved block")) {
        this.innerHTML = 'changed';
    }
});

===

update

              $("tbody tr td.actionclass").each(function() {       
                var ratingTdText = $(this).text();
                console.log(ratingTdText);
                if(($(this).is(':contains("new")')) || ($(this).is(':contains("saved")'))) {
                        (this).text().replace("top", "TopBar"); 
                         (this).text().replace("left", "LeftBar"); 
                          (this).text().replace("bottom", "BottomBar"); 

                }

            });  

InformationsquelleAutor hansi silva | 2017-03-19

Schreibe einen Kommentar