I am trying to create a logic that if anyone enters "<p>" and "</p>" characters inside <textarea>, then only Jquery should show the win message.I have a textarea with class html, a h2 with class result which shows win or loss.By now, I have this code:
var html = $('.html').val();
if(html.indexOf("</p>" && "<p>") === -1)
{
document.getElementById("result").innerHTML = "You lost it.";
}
else{
document.getElementById("result").innerHTML = "Hurray!You won";
}
But, this code is only checking if the <p> is there and not checking for </p>.So what can I do....
html.indexOf("</p>" && "<p>")- is that valid to have&& <expr>insideindexOf?"</p>" && "<p>" === "<p>", you'll need to check both and then compare results.