1 | initial version |
You can retrieve the text from a span using jQuery by using the .text()
method. Here's an example:
// HTML
<span id="my-span">Hello, world!</span>
// jQuery
var text = $('#my-span').text(); // retrieves the text inside the span element
console.log(text); // prints "Hello, world!" to the console
In the above example, we select the span element using its ID and then use the .text()
method to retrieve the text inside it. We then store the text in a variable called text
and print it to the console using console.log()
.