Hello:
I am trying to write a javascript function with an "if" statement that will execute a command if the text between two tags match. I have been able to write many "if" statements in which a command is executed when the value within an input textbox equals that of the "if" statement criteria such as:
function Test()
{
if (document.getElementById('A').value == 1)
{
alert('test');
}
}
<input type="button" id="B" onCLick="Test()"/>
<input type="text" id="A"/>
When I enter "1" in the textbox and press the button, an alert box will appeare. The problem that I am having is that I would like to do the same with text bewteen two tags. For example:
function Test()
{
if (document.getElementById('A').value == 1)
{
alert('test');
}
}
<input type="button" id="B" onCLick="Test()"/>
<p id="A">1</p>
In my project I would be using words instead of numbers, so I understand that I would have to surround the word in quotes. Unfortunately, this doesn't work. Is it possible to write an "if" statement like the one above that determines if text between two tags is true? Also, I have tried document.getElementById('A').text, and document.getElementById('A').innerHTML, but none of those made a difference. I ave even tried using one equal sign instead of two; however, that would make all criteria true, regardless if it were true or not.
Thanks
DFM