0

I am trying to see is the selected text has a set of words inside it and then replace it or surround it with the span tag on line 22.

<!DOCTYPE html>
<html>

<head>
    <title>Document</title>
    <style>
        .danger {
            color: red;
            font: bold;
        }
    </style>
</head>

<body>
    <p class="air-section"> blah blah blah This is dangerous blah blah
    </p>
</body>
<script>
    const section = document.querySelector('.air-section');
    if (section.textContent.includes('This is dangerous')) {
        console.log(section.innerText);
        section.textContent.replace(/This is dangerous/g, '<span class="air-text-entry air-entry danger" style="display: block; color: #E2E7E9; margin: 5px;">This is dangerous</span>');
    }
</script>

</html>

0 Answers0