编程语言
首页 > 编程语言> > 今天的Django教训汇总:Javascript根据数值变化颜色-20211107

今天的Django教训汇总:Javascript根据数值变化颜色-20211107

作者:互联网

Javascript根据数值变化颜色

<!-- 调整color的js脚本开始 -->
<script>
    window.onload = function(){
        paradom1 = document.getElementsByClassName("p1")
        console.log(paradom1)
        for (i = 0 ; i < paradom1.length; i++) {
            var para = document.getElementsByClassName("p1")[i];if (para.textContent <=35) {para.style.color = "red";}else if (para.textContent <65) {para.style.color = "orange";}else{para.style.color = "green";}
        }
    }
</script>
<!-- 调整color的js脚本介绍 -->

标签:20211107,style,getElementsByClassName,para,color,Javascript,Django,paradom1
来源: https://blog.csdn.net/m0_46629123/article/details/121199044