<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /><title></title><script src="js/mui.min.js"></script><link href="css/mui.min.css" rel="stylesheet" />
</head>
<body><div id="div1">div1</div><div id="div">div2</div><div id="div2" class="nw1">div3</div><input type="button" name="text" id="" value="666" /><script src="js/mui.js" type="text/javascript" charset="utf-8"></script><script type="text/javascript">console.log(mui(‘div‘)[0].innerHTML);//mui做dom操作必须先加【0】转为dom元素console.log(mui(‘input‘)[0].value);//mui括号里的可以是id、标签、class属性//getartvar lui=mui(‘input‘)[0];//mui方式获取input对象console.log(lui.attributes.type.nodeValue);//获取input标签的type属性值console.log(lui.attributes[‘name‘].nodeValue);//另一种获取input标签的name属性值console.log(document.getElementById(‘div‘).innerHTML);//这里是js的方法var nw=document.getElementById(‘div2‘);nw.setAttribute(‘demo‘,‘demo1‘);//设置自定义属性和值console.log(nw.attributes[‘demo‘].nodeValue);var nw1=document.getElementsByClassName(‘nw1‘)[0].innerHTML;console.log(nw1);(function($){//这里是在闭包里使用mui获取元素console.log($(‘div‘)[0].innerHTML);})(mui);</script></body>
时间: 2024-10-20 09:42:09