How to Select Elements with IDs Containing a Specific String and Ending with a Specific Text?

Patricia Arquette
Release: 2024-10-27 18:40:02
Original
340 people have browsed it

How to Select Elements with IDs Containing a Specific String and Ending with a Specific Text?

CSS Selector: Retrieving Elements with IDs Containing a Specific String

Your question pertains to acquiring all elements with IDs containing a portion of a given text, in this case, "Some:Same". While you've attempted to use "a[id*='Some:Same']", it returns all elements with IDs containing "Some:Same", which includes unwanted results.

To narrow down the selection, consider the following CSS selector:

a[id*='Some:Same'][id$='name']
Copy after login

This selector will retrieve all "a" elements whose IDs contain the text "Some:Same" and additionally end with the text "name". The "=" operator in "id='Some:Same'" indicates that the ID should contain "Some:Same" anywhere within its value, while "$=" in "id$='name'" ensures that the ID ends with "name".

By employing this refined selector, you can effectively extract only those elements you're interested in. This approach offers a more targeted selection mechanism compared to your previous attempt.

The above is the detailed content of How to Select Elements with IDs Containing a Specific String and Ending with a Specific Text?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!