yo1.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="description" content="Webpage description goes here" />
  5. <meta charset="utf-8">
  6. <title>Change_me</title>
  7. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <meta name="author" content="">
  10. </head>
  11. <body>
  12. <div class="container">
  13. <div id='info'></div>
  14. <table>
  15. <tr>
  16. <td><input type="hidden" value="3" />3</td>
  17. <td><input type="hidden" value="1" />1</td>
  18. <td><input id="tar" type="text" value="2" onchange="checkRange(this);" /></td>
  19. </tr>
  20. </table>
  21. </div>
  22. <script>
  23. function checkRange(ele)
  24. {
  25. if(parseFloat(ele.value) > parseFloat(ele.parentNode.previousElementSibling.previousElementSibling.childNodes[0].value))
  26. $('#info')[0].innerHTML = "超出上限";
  27. else if(parseFloat(ele.value) < parseFloat(ele.parentNode.previousElementSibling.childNodes[0].value))
  28. $('#info')[0].innerHTML = "超出下限";
  29. else
  30. $('#info')[0].innerHTML = "";
  31. //console.log(ele.parentNode.previousSibling);
  32. }
  33. //console.log($('#tar')[0].parentNode);
  34. </script>
  35. </body>
  36. </html>