Skip to content

Commit

Permalink
🔖 release 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rowthan committed Jan 21, 2018
1 parent 3ba6859 commit 257c8b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>点击下列<b>粉色内</b>区域预览计算结果</p>
<section class="demo">
<div class="id-locate">
<p style="text-align: left">元素本身具备 id 属性情况下:(点击 id=)</p>
<p style="text-align: left">元素本身具备 id 属性情况下:</p>
<span id="singleId">id=<b>singleId</b>id唯一</span>
<span id="multiId">id=<b>multiId</b>id不唯一时</span>
<span id="multiId">id=<b class="special">multiId</b>与前一个元素id相同</span>
Expand Down
Binary file modified img/draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 10 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
> 定位一个网页DOM元素,一般会通过 id,class,name 作为标识符,通过 `document.getElementById()``document.getElementByName()` `document.querySelector()`
原生API来定位获取指定元素。而针对一些节点,如 `<span>文本</sapn>` 是否有方法定位到它们呢?
> 定位一个网页DOM元素,一般会以 id,class,name 作为标识符,通过 `document.getElementById()``document.getElementByName()` `document.querySelector()`
原生API来定位获取指定元素。而针对一些无任何标识的节点,如 `<span>文本</sapn>` 是否有方法定位到它们呢?
## 使用方法
### 方式一、引入JavaScript文件
下载 whatselement.js
demo.html 中使用:

demo.html
```javascript
<script src="whatsElement.js"></script>

var whats = new whatsElement();
document.addEventListener('mousedown', (event) => {
if(event.button === 2){
const target = event.target;
const result = whats.getUniqueId(target);
}
const target = event.target;
const result = whats.getUniqueId(target);
})
```

Expand All @@ -25,12 +23,10 @@ npm install whats-element --save
demo.js
```javascript
import whatsElement from 'whats-element';
var comput = new whatsElement();
var whats = new whatsElement();
document.addEventListener('mousedown', (event) => {
if(event.button === 2){
const target = event.target;
comput.getUniqueId(target);
}
const target = event.target;
const result = whats.getUniqueId(target);
})
```

Expand Down Expand Up @@ -69,7 +65,4 @@ whatsElement 提供以下方法
var compute = new whatsElement({draw:false});//传入参数{draw:false}
var result = comput.getUniqueId(HTMLElement);
```
* *`whatsElement.clean()`* 删除 `whatsElement.draw()` 在网页中绘制的提示框。

TODO 绘制该元素的相关信息,如高度宽度背景图片,右侧缩略位点
将关闭按钮设置为 固定住按钮。固定后可以拖拽
* *`whatsElement.clean()`* 删除 `whatsElement.draw()` 在网页中绘制的提示框。

0 comments on commit 257c8b0

Please sign in to comment.