- 博客(10)
- 收藏
- 关注
jw.min.js自制javascript库
一、使用$()函数创建jwHTMLElement类,$()有两种使用方式:
1.$(string),string是选择器字符串,和css选择器类似,但input[type=xxx]简化为input:xxx,会返回一个jwHTMLElement对象。
2.$(dom),dom是获取到的dom元素,会返回一个jwHTMLElement对象。
例子:
<button class="glass-button">
<span id="asd">玻璃按钮</span>
</button>
<script>
jwhtmlelement=$("#asd");
</script>
二、使用jwHTMLElement.create()创建jwHTMLElement类:
jwHTMLElement.create(str),str为元素名称,如div、input等。
例子:
var input=jwHTMLElement.create("input");
重点:
不会自动添加至dom,请调用对象的add
2025-04-13
glass.css是一款玻璃按钮css
导入CSS后写下面HTML代码使用
<button class="glass-button">
<span>玻璃按钮</span>
</button>
2025-04-13
html js自制jw.js,使用方法如下
一、使用$()函数创建jwHTMLElement类,$()有两种使用方式:
1.$(string),string是选择器字符串,和css选择器类似,但input[type=xxx]简化为input:xxx,会返回一个jwHTMLElement对象。
2.$(dom),dom是获取到的dom元素,会返回一个jwHTMLElement对象。
例子:
<button class="glass-button">
<span id="asd">玻璃按钮</span>
</button>
<script>
jwhtmlelement=$("#asd");
</script>
二、使用jwHTMLElement.create()创建jwHTMLElement类:
jwHTMLElement.create(str),str为元素名称,如div、input等。
例子:
var input=jwHTMLElement.create("input");
重点:
不会自动添加至dom,请调用对象的add方法:
input.add();
三、jwHTMLElement的方法:
1.设置html内容,使用对象的html属性即可。
2.设置文字内容,使用对象的html属性即可。
3.设置css内容,使用对象的css(属性,内容)即可。
4.获取dom对象,使用对象的dom属性即可。
5.设置属性setAttr(属性名,属性值),获取属性getAttr(属性名)。
6.动画方法:
(1)show和hide方法,用于显示或隐藏元素
(2)empty或delete方法,用于清空内容或删除元素
7.类方法:
(1)addClass(类名)用于
2025-04-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人