muhammet okay
muhammet okay

Reputation: 23

How can i get the text of a span element using javascript?

Edited for tags and further explanation of the question

Hello ,i am fairly new to the web programming, sorry in advance if this sounds out of place. My question is, i need to get customer's name and number from this <span class="tag-element-content" title="${Customer No}">${Customer Name}-${Customer No}</span> area, which is inside the code below, any help would be very appreciated.

<div class="tagger" id="ChoosenCustomer">
                                        <div class="tags-container tag-view focused" id="branches">
                                            <div class="tag-element-container" dojoattachpoint="_tagsContainer">
                                                <div class="tag-decorated-element" name="ChoosenTags" id="" is-clicked="true">
                                                    <span class="tag-element-content" title="${Customer No}">${Customer Name}-${Customer No}</span>
                                                    <span id="RemoveCustomer" class="tag-element-delete icon-cross" search-id="" click=DeleteCustomer()></span>
                                                    <input type="hidden" id="" value="${Customer No}" is-clicked="true">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

Upvotes: 0

Views: 253

Answers (3)

Pedram Gholizadeh
Pedram Gholizadeh

Reputation: 178

Simply you can use jquery on your project and :

var SpanText = $('.tag-element-content').text();

Upvotes: 0

my profile
my profile

Reputation: 37

in your case:

document.getElementById("anid").innerText;

and add the id to your element

Upvotes: 0

Nitin Shinde
Nitin Shinde

Reputation: 165

try this:

let span_text = document.querySelector('.your-element-class').textContent;

with jQuery:

let span_text = $('.your-element-class').text();

Upvotes: 1

Related Questions