String variable returned object in Javascript -
i have problem variable string return [object object]
$(document).ready(function () { $(".story-area > h1").text(function () { return $(this).text(convertstring($(this).text())); }); $(".story-area > p").text(function () { return $(this).text(convertstring($(this).text())); }); $(".story-area > div > p").text(function () { return $(this).text(convertstring($(this).text())); }); }); function convertstring(current_text) { var arr_text = current_text.split(' '); var new_text = ''; (i = 0; < arr_text.length; i++) { if (arr_text[i].length > 4) { new_text += arr_text[i].replace(/[hh][ii]/g, 'hiv') + ' '; } else { new_text += arr_text[i] + ' '; } } return new_text; }
the new_text value returns [object object]
instead of string value. errors on code?
ah, setting text inside of setting text! treating text() each.
$(".story-area > h1").text(function () { return convertstring($(this).text()); });
Comments
Post a Comment