jQuery replace text leaving siblings intact

后端 未结 4 1604
清歌不尽
清歌不尽 2020-12-29 10:29

I\'m having trouble wrapping my head around what should be a simple solution. I want to replace text within a label tag, without affecting the other \'siblings\', if they ex

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 10:54

    Why not simply do an entire replace using regex?

    $(".myFieldsetClass label:contains('Some Label ')")
        .each(function() {
                $(this).html($(this).html().replace(/Some Label ./, "Some Label")); 
            });
    

提交回复
热议问题