Home  >  Article  >  Web Front-end  >  How to Retrieve Specific `` Text in jQuery?

How to Retrieve Specific `` Text in jQuery?

DDD
DDDOriginal
2024-10-26 15:43:03451browse

How to Retrieve Specific `` Text in jQuery?

Retrieving Specific

This article addresses the challenge of obtaining the text content of a particular

<code class="html"><select id='list'>
    <option value='1'>Option A</option>
    <option value='2'>Option B</option>
    <option value='3'>Option C</option>
</select></code>

Getting

To retrieve the text of an

<code class="javascript">$("#list option[value='2']").text();</code>

In this example, we're targeting the

Getting Text of Selected

If you wish to obtain the text of the currently selected

<code class="javascript">$("#list option:selected").text();</code>

This selector will return the text of the

The above is the detailed content of How to Retrieve Specific `` Text in jQuery?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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