我现在有这段代码:
<div>
用户名:<input type="text" name="test" />
密码: <input type="password" name="pass" />
</div>
我想删除div里头的所有 这个用jquery如何实现呢?
jquery
html
删除空格
------解决方案--------------------
$("#xxx").html($("#xxx").html().replace(/ /g,""))
------解决方案--------------------
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#abv").click(function(){
var content1=$("div").html();
var content2=content1.replace(/\ \;
------解决方案--------------------
\ /g,'');
$("div").html(content2);
});
})
</script>
<div>
用户名:<input type="text" name="test" />
密码: <input type="password" name="pass" />
</div>
<input type="button" id="abv" value="清除空格"/>