- 1 "-//W3C//DTD Xhtml 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 2 "http://www.w3.org/1999/xhtml" > 3 4 5 "jquery.min.js"type = "text/javascript" > 6 "javascript"type = "text/javascript" > 7 $(document).ready(function() {
- 8 aa("", 1);
- 9
- });
- 10 11
- function aa(a, s) {
- 12
- var lb_va = "";
- 13
- if (s == 1) {
- 14 lb_va = document.getElementById("lb").innerText;
- 15
- }
- 16
- else {
- lb_va = a;
- }
- 17 lb_va = $.trim(lb_va);
- 18
- var div1 = document.getElementById("diva");
- 19
- if (lb_va.length == 1) {
- 20 div1.style.width = "15px";
- 21 div1.style.right = "-15px";
- 22 div1.style.top = "-10px";
- 23
- } else if (lb_va.length == 2) {
- 24 div1.style.width = "20px";
- 25 div1.style.right = "-15px";
- 26 div1.style.top = "-10px";
- 27
- }
- 28
- else if (lb_va.length == 3) {
- 29 div1.style.width = "30px";
- 30 div1.style.right = "-15px";
- 31 div1.style.top = "-10px";
- 32
- }
- 33
- else if (lb_va.length == 4) {
- 34 div1.style.width = "40px";
- 35 div1.style.right = "-15px";
- 36 div1.style.top = "-10px";
- 37
- }
- 38
- }
- 39 40
- function Trim(str, is_global) {
- 41
- var result;
- 42 result = str.replace(/(^\s+)|(\s+$)/g, "");
- 43
- if (is_global.toLowerCase() == "g") {
- 44 result = result.replace(/\s/g, "");
- 45
- }
- 46
- return result;
- 47
- }
- 48 49
- function ti() {
- 50
- var a = $("#tx").val();
- 51 $("#lb").html(a);
- 52 aa(a, 0);
- 53
- }
- 54 55 "text/CSS" > 56.divv 57 {
- 58 height: 20px;
- /* width: 20px;
- 59 right: -25px;
- 60 top: -10px;*/
- 61 float: right;
- 62 position: relative;
- 63 background - color: #FF3B30;
- 64 text - align: center;
- 65 color: Black;
- 66 border - radius: 10px;
- 67 border: solid rgb(100, 100, 100) 1px;
- 68
- }
- 69.divvv 70 {
- 71 border: 1px solid#ccc;
- 72 width: 40px;
- 73 height: 40px;
- 74 margin - top: 100px;
- 75 background - image: url('Style / image / setting.png');
- 76 background - repeat: no - repeat;
- 77
- }
- 78 a 79 {
- 80 text - decoration: none;
- 81
- }
- 82 83 84 85 "text"id = "tx" / >86 "button"id = "btn_tijiao"value = "提交"onclick = "ti()" / >87 class = " divvv" > 88 "diva"class = "divv" > 89 "lb" > 90 1111 91 92 93 94
来源: http://www.bubuko.com/infodetail-1955367.html