1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta name="description" content="Webpage description goes here" />
- <meta charset="utf-8">
- <title>Change_me</title>
- <script src="http://code.jquery.com/jquery-latest.min.js"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="author" content="">
- </head>
- <body>
- <div class="container">
- <div id='info'></div>
- <table>
- <tr>
- <td><input type="hidden" value="3" />3</td>
- <td><input type="hidden" value="1" />1</td>
- <td><input id="tar" type="text" value="2" onchange="checkRange(this);" /></td>
- </tr>
- </table>
- </div>
- <script>
- function checkRange(ele)
- {
- if(parseFloat(ele.value) > parseFloat(ele.parentNode.previousElementSibling.previousElementSibling.childNodes[0].value))
- $('#info')[0].innerHTML = "超出上限";
- else if(parseFloat(ele.value) < parseFloat(ele.parentNode.previousElementSibling.childNodes[0].value))
- $('#info')[0].innerHTML = "超出下限";
- else
- $('#info')[0].innerHTML = "";
- //console.log(ele.parentNode.previousSibling);
- }
- //console.log($('#tar')[0].parentNode);
- </script>
- </body>
- </html>
|