[Solved] How can I Bold First two words bold in a paragraph Dynamically? [closed]


You can achieve this as below:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
    <p class="boldTwoWord">How can I Bold First two words bold in a paragraph Dynamically?</p>
    <br/>
    <p class="boldTwoWord">I am trying to bold first two words in the Paragraph what can i do ? for that</p>    
</body>
<script type="text/javascript">
    var elms = $(".boldTwoWord");
    for (var i = 0; i < elms.length; i++) {
        str = elms[i].innerText;
        var ret = str.split(" ");
        var str1 = ret[0];
        var str2 = ret[1];

        s1 = str.replace(str1, '<strong>$&</strong>');
        s2 = s1.replace(str2, '<strong>$&</strong>');
        elms[i].innerHTML = s2;
    }
</script>
</html>

solved How can I Bold First two words bold in a paragraph Dynamically? [closed]