I have tried to make an if statement to check if a variable is 2. But everytime I try, I get the else statement. Here's my Javascript:
$(document).ready(function() {
$('#test').html(2);
var antkeepere = document.getElementById('test');
if(antkeepere==2){
$('#mer').html('Ja!')
}
else{
$('#mer').html('Nei!')
};
});
First I wrote 2 in my html, but it didn't work. THen I tried to make it 2 through js as in the example over, but it didn't work either. I have searched through other threads like this and tried to but .value both in the if statement and when creating the variabel, but none of them worked either.
DOMobject with a number. They are different