简体   繁体   中英

compare in javascript innerHTML and value

I need to compare the javascript condition below : but I get only false How can I fix that ?

if(document.getElementById('captchaTypedValue').innerHTML == String(document.getElementById('login:inputCodSeg').value))

returns me false

captchaTypedValue is span element
login:inputCodSeg is input element

javascript chromium console

在此处输入图片说明

Here:

if(document.getElementById('captchaTypedValue').innerHTML == String(document.getElementById('inputCodSeg').value)) {
    // do stuff
}

basically I think you don't have an ID called login:inputCodSeg . If that doesn't work, it's probably because the condition simply is not true.

ALSO:

if you would like to use jquery:

if ( $('#captchaTypedValue').html() == $('#inputCodSeg').val() ){  
   // do stuff    
}

should work

EDIT: there's also a chance that the condition is just not true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM