jquery根据属性选择
发表于|更新于
|浏览量:
有信仰的人不会孤独。——阿列克谢耶维奇
分享一个jquery选择器的小技巧
我们可以通过自定义属性键值选中一个元素
例如如下元素:
1 | <div ruben="vampire">阿超</div> |
然后我们通过ruben=vampire选中这个div
就可以如下写法:
1 | let vampire = $('div[ruben="vampire"]') |
我们可以简单测试一下输出里面的内容
1 | <div ruben="vampire">阿超</div> |
效果

相关推荐
2024-11-10
typescript-exercises(十五)
人的一辈子都在高潮—低潮中浮沉,唯有庸碌的人,生活才如死水一般。——傅雷 问题: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051/*Intro: Our attempt to Open Source didn't work quite as expected. It turned out there were already many existing functional JS libraries. All the remaining developers left the company as well. It seems that they are joining a very ambitious startup which re-invented a juicer and raised millions of dollars. Too bad we cannot compe...
2024-08-12
gitpod运行shenyu-dashboard
即使为了国王的宝座,也永远不要欺骗、违背真理。——贝多芬 方式很简单,访问: Dashboard 然后一步一步操作注册登录,我这里选择的暗黑模式以及Idea 网站自动打开了我的Jetbrains Gateway,然后开始下载依赖 后面即可正常进行开发
2024-10-29
typescript-exercises(三)
青年人的教育是国家的基石。——富兰克林 题面: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970/*Intro: Since we already have some of the additional information about our users, it's a good idea to output it in a nice way.Exercise: Fix type errors in logPerson function. logPerson function should accept both User and Admin and should output relevant information according to the input: occupation for User an...
2024-12-25
js录音并播放demo
伟大变为可笑只有一步,但再走一步,可笑又会变为伟大。——佩思 代码如下: 1
2022-07-15
vuera
微微怪时间不能保存情绪,保存那一切情绪所曾流连的境界。——《你是人间的四月天》 分享一个开源项目:https://github.com/akxcv/vuera 它可以让你在vue里写react,在react里写vue Use Vue components in your React app: 1234567import React from 'react'import MyVueComponent from './MyVueComponent.vue'export default props => <div> <MyVueComponent message={props.message} handleReset={props.handleReset} /> </div> Or use React components in your Vue app: 1234567891011121314<template> <div&g...
2022-06-19
ts中枚举
现实生活喜欢对称和轻微的时间错移。——博尔赫斯《南方》 填坑,官方文档:https://www.typescriptlang.org/docs/handbook/enums.html 我新建了一个vue项目用来演示 这里代码如下: 12345678910enum Direction { Up, Down, Left, Right}console.log({ Direction });console.log({ 'Object.entries(Direction)': Object.entries(Direction) });console.log({ 'Direction[0]': Direction[0] });console.log({ 'Direction.Up': Direction.Up }); 打印结果如下: 定义一个双向绑定的值 1const count = ref(Direction.Up)...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog