根据ID选择元素的最佳方法是什么 [英] What is the best way to select elements based on ID

查看:123
本文介绍了根据ID选择元素的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JQuery中基于ID选择元素的最佳方法是什么



What is the best way to select elements based on ID in JQuery

$('[id=iden]');




where


    var iden = e.target.id;

推荐答案

(< span class =code-string>' [id = iden]');




where


    var iden = e.target.id;


id是一个标准的HTML属性,所有HTML元素都有(即使你没有直接定义),jQuery单独解决它而不是任何其他属性...

格式为
id is a standard HTML attribute, that all HTML element has (even you didn't defined it directly) and jQuery addresses it separately and not as any other attribute...
The format is


('#id') ...

https://api.jquery.com/id-selector/ [ ^ ]

https://api.jquery.com/category/selectors/ [ ^ ]
('#id')...
https://api.jquery.com/id-selector/[^]
https://api.jquery.com/category/selectors/[^]


这篇关于根据ID选择元素的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆