标签:style blog color io ar div sp cti log
<input type="text" value="" class=\"queryInput\" />
var curNode = "input.queryInput"; var curWidth = $(curNode).eq(0).width(); var curMaxWidth = 700; $(curNode).eq(0).keyup(function() { var curTxtWidth = $(curNode).eq(0).width(); var node = $("#widthAuto"); if (node.length > 0) { node = $("#widthAuto"); node.html($(this).val()) } else { node = $("<span id=\"widthAuto\" style=\"visibility:hidden;\">" + $(this).val() + "</span>"); $("body").append(node) } var curAllWidth = node.width() + 149; if (curWidth > curAllWidth) { $(curNode).eq(0).css("width", curWidth) } else { if (curMaxWidth > curAllWidth) { $(curNode).eq(0).css("width", curAllWidth) } } })
记得引用Jquery!
标签:style blog color io ar div sp cti log
原文地址:http://www.cnblogs.com/xyzhuzhou/p/3979109.html