Selecting elements by name with wildcards

2019-08-31 21:55发布

Whats a good way to select elements by their name using wildcards?

The website has element names in the form of <a_1786439></a_1786439> which are likely auto-generated. This is doable by xpath, but is it doable using css selectors or jquery selectors which are faster?

This is clearly terrible-coding, but the website is not mine, and I'm writing a userscript for it.

2条回答
神经病院院长
2楼-- · 2019-08-31 22:13

It's possible to create custom elements using the HTML DOM createElement method like this:

document.createElement('Funny_Element');

In the website code you are dealing with, they have created a custom element, or maybe extend the a element, but they didn't choose a significant name! a_1786439??? which is, I think, really bad.

Using CSS selectors or jQuery selectors depends essentially on what you want to do. Suppose you have to access children elements of a specific node, then jquery selectors would be more appropriate.

Hope it's useful!

查看更多
Ridiculous、
3楼-- · 2019-08-31 22:26

This doesn't exist in CSS3, as the spec's section on type selectors only includes names and wildcards, but no combinations of them.

查看更多
登录 后发表回答