<input type="text" size="4" value="10" name="fileSizeLimit" id="fileSizeLimit"/>K<input type="file" name="file1" id="file1" size="40" onchange="changeSrc(this)"/><img src="about:blank" id="fileChecker" alt="test" height="18"/> //前面为网页<script type="text/javascript">var oFileChecker = document.getElementById("fileChecker") function changeSrc(filePicker){oFileChecker.src = filePicker.value//读图片}//这个很重要,判断是否完全读完,否则判断图片大小不准确oFileChecker.onreadystatechange = function (){ if (oFileChecker.readyState == "complete") {checkSize()}}function checkSize(){ var limit = document.getElementById("fileSizeLimit").value * 1024if (oFileChecker.fileSize >limit) {alert("too large")} else {alert("ok")}}</script>就如同你问题一样,判断一下对应的数值,根据其范围改变
样式属性或者更变class属性
如:
var div=document.getElementById('jaoyi')
var num = parseInt(div.innerHTML,10)
if(num>50){div.style.color='red'}else{div.style.color='blue'}//直接改变样式属性
if(num<80){div.className='red'}else{div.className='blue'}//更换class
兄弟,就是这么写的
var x=math.random()
var y=math.random()
document.write(x>y?x:y)
评论列表(0条)