Comments (4)
@zhangxianhong 针对表单元素,的确缺失一个 .val()
方法,我来加一下,晚点再更新一版~
from visdom.
@zhangxianhong 发布了v0.4.13版本,新增了 .val()
方法,现在可以比较方便的获取select等表单元素的选取值了,另外配套增加了 ":checked" 伪类,方便获取到单选框、多选框选中的元素并做下一步操作。如果使用中还有其它问题,欢迎随时反馈~!
let html = r##"
<!doctype html>
<html>
<body>
<select>
<option value="1">1</option>
<option value="2" selected="true">2</option>
<option value="3">3</option>
</select>
</body>
</html>
"##;
let doc = Vis::load(html)?;
let select = doc.find("select");
// 新增了 '.val()' 方法,可以获取select/input/textarea/option等表单元素的值
assert_eq!(select.val().to_string(), "2");
// 新增了 ':checked' 伪类选择器,可以选择
let selected_option = select.find("option:checked"); // 这里等价于 select.find("option[selected]");
assert_eq!(selected_option.val().to_string(), "2");
from visdom.
@fefit 感谢,这么快的迭代发布,这个实现比较简洁;正是我需要的,解决了我的大问题,再次感谢!
from visdom.
:) 太客气了,有问题随时交流~!
from visdom.
Related Issues (20)
- error: failed to get `mesdoc` as a dependency of package `visdom v0.1.4 HOT 1
- 带:冒号的怎么解析? HOT 9
- 内存泄漏 HOT 6
- 如何获取节点的tag name(节点名称)? HOT 3
- 将`Result<Elements, Box<dyn Error>>` 改为`Result<Elements, Box<dyn Error + Send>>` HOT 2
- Opposite of .has() HOT 4
- doc.find("p:contains('好用')" panicked, only when Chinese characters appear in contains() HOT 2
- How to remove a DOM element? HOT 6
- No problem, my bad :(
- Please add support for html method for all elements HOT 5
- Navigating sideway with `find` method HOT 2
- set_html and replace_with seems not work HOT 6
- 这么好的项目为什么这么少人知道? HOT 1
- 不可用 HOT 2
- `rphtml` and `htmlentities` APIs changed HOT 3
- Stripping class entirely HOT 2
- Does this support xpath selectors ? HOT 4
- 缺少类似jquery的clone HOT 6
- `Vis::load`返回的结果应该自动选中root元素 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from visdom.