2012-07-19 35 views

回答

0

你可以尝试用常规的文本框已被移动在它上面的图像所以不会惹的背景图像。

HTML

<div class="clearable"> 
    <input type="text"/> 
    <img src="http://www.hanebutt.co.uk/uploads/content/close_x.gif" /> 
</div> 

CSS

.clearable img {position: relative; left: -20px;} 

jQuery的

$(document).ready(function() { 
    $('.clearable img').click(function() { 
    var theInput = $(this).parent().find('input'); 
    theInput.val(""); 
    theInput.focus(); 
    }); 
}); 

你可以看到它在这里的行动:http://jsbin.com/afafet

相关问题