How to change a text with jQuery

前端 未结 7 1636
执念已碎
执念已碎 2020-12-03 00:24

I have an h1 with id of toptitle that is dynamically created, and I am not able to change the HTML. It will have a different title depends on a pag

7条回答
  •  隐瞒了意图╮
    2020-12-03 00:47

    Something like this should do the trick:

    $(document).ready(function() {
        $('#toptitle').text(function(i, oldText) {
            return oldText === 'Profil' ? 'New word' : oldText;
        });
    });
    

    This only replaces the content when it is Profil. See text in the jQuery API.

提交回复
热议问题