I have a radar_box div which is color #7eb6ff, i want to change the color to red if the jsonstr value in external javascript file is above 100. my code is so far doing nothing:
html:
<script type="text/javascript" src="../declare.js"></script>
<section id="alert">
<h1>alert</h1><br><br>
<div class="radar_box_area">
<div class="radar_box" id="radar_box">
<div class="radar"></div>
</div>
</div>
<script>
var mmm=document.getElementById("radar_box");
function cond(){
if(jsonstr > 100){
mmm.style.backgroundColor("red");
}}
</script>
</section>
my declare.js file:
var jsonstr = ["131.05\r\n"]
if the solution is to write my condition in js file, i can't do it because declare.js is created when i run python code. so the whole file is rewritten.
in cond function use this snippet.
what we done here is just replace any spaces, convert return str to number by using + sign and then compare with value.
var jsonstr = ["131.05\r\n"];
const check = +jsonstr[0].replace(/(\r\n|\n|\r)/gm, '')
if (check > 100) {
console.log('in', check)
}