문서의 이전 판입니다!
function escapeHtmlEntities (str) { if (jQuery !== undefined) { // Create an empty div to use as a container, // then put the raw text in and get the HTML // equivalent out. return jQuery('<div/>').text(str).html(); } // No jQuery, so use string replace. return str .replace(/&/g, '&') .replace(/>/g, '>') .replace(/</g, '<') .replace(/"/g, '"') .replace(/'/g, '''); // Do not use "'", IE does not support. }