jquery 中遍历数组
var arr = [1,2,3,4,5] $.each(arr,function(i,j){ console.log(i,j) })
结果
0 1
1 2
....
jQuery 中遍历字典
let obj = {'name': 'lll', 'age': 15}
$.each(obj, function (i, j) {
console.log(i, j)
})
结果
name lll
age 15
jquery 循环标签
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<script>
$('ul li').each(function (i, j) {
console.log(i, j)
console.log($(this).html())
})
</script>
jquery中删除父节点
parentEl=$(this).parent() parentEl.remove()
jquery 取file类型中的值
$("#files")[0].files[0]
jquery取url中参数
location.search "?postid=1123123&update=1" #切去几位,后面返回 location.search.slice(1) location.href "https://i.cnblogs.com/EditPosts.aspx?postid=1132312121&update=1"
jquery 生成图片验证码请求
var preimageCodeId = "" function generateImageCode() { //生成随机字符串 imageCodeId = generateUUID() //拼接url路径,携带随机字符串参数 image_url = "/passport/image_code?cur_id=" + imageCodeId + "&pre_id=" + preimageCodeId //设置到图片标签中 $(".get_pic_code").attr("src",image_url) //记录上一次的随机字符串 preimageCodeId = imageCodeId }