根据ID选择元素的最佳方法是什么

根据ID选择元素的最佳方法是什么

问题描述:

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



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

$('[id=iden]');




where


    var iden = e.target.id;

(' [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/[^]