$(function() { var phone = $('#phone').text(); var mphone = phone.substr(0, 3) + '****' + phone.substr(7);
此时mphone 的值就是中间四位显示为*号的了; $('#phone').text(mphone) });