<div id="hpic">
<img src="images/1.jpg"/>
<img src="images/2.jpg"/>
<img src="images/3.jpg"/>
</div>
<script>
$(function(){
var img = $("#hpic img");
img.each(function(e,img){
var src = img.src.split('/').pop();
console.log(src);
});
})
</script>
<div class="hk1">
<div>-----------------------◆</div>
<div class="hk2">居中散开</div>
<div>◆-----------------------</div>
</div>
<style>
.hk1{
margin: 0 auto;
width: 300px;height: 100px;
background-color: orange;
display: flex;
display: -webkit-flex;
flex-flow:row nowrap;
justify-content:center;
align-items:center;
white-space:nowrap;
overflow: hidden;
}
.hk1 .hk2{ margin: 20px }
</style>
1、简单版
<input onkeyup="if(isNaN(value))execCommand('undo')">
2、正则表达式替换
<input name="num">
<script>
$("input[name='num']").on("input",function(){
this.value =this.value.replace(/[^\d.]/g,"");
this.value = this.value.replace(/^\./g,"");
this.value = this.value.replace(/\.{2,}/g,".");
console.log(this.value);
return this.value = this.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
})
</script>
- 移除input在type=”number”时的上下小箭头
<style>
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button{
-webkit-appearance: none !important;
}
input[type="number"]{-moz-appearance:textfield;}
</style>