jQuery onload replace specific text

时间:2018-06-04 16:43:34

标签: javascript jquery

$(document).ready(function() {    
    var text = $(".name")
    return $(this).text().replace("★", "  ★");
});

This is what I have right now but doesn't seem to work idk why?

I used to have code that did work just only in chrome console.

$(".name").text(function() {
    return $(this).text().replace("★", " ★");
});

1 个答案:

答案 0 :(得分:0)

I think this is more what you're looking for:

$(document).ready(function() {
  $(".name").text(function(i, text) {
    return text.replace("★", "  ★");
  });
});