Using Regex and replace method will escape single quote in string variable in JavaScript.
<!DOCTYPE html>
<html>
<body>
<div id="div1">Men's and Women's something.</div>
<script>
var str = document.getElementById("div1").innerHTML;
console.log(str.replace(/'/g,"\\'"));
</script>
</body>
</html>
Output:

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version