Get value of Span Text

后端 未结 5 1114
萌比男神i
萌比男神i 2020-12-05 01:37

I have a span with class=\"span\" and a hidden field class=\"dropdown\".

The span text changes, and I need to grab the text an

5条回答
  •  日久生厌
    2020-12-05 02:15

    The accepted answer is close... but no cigar!

    Use textContent instead of innerHTML if you strictly want a string to be returned to you.

    innerHTML can have the side effect of giving you a node element if there's other dom elements in there. textContent will guard against this possibility.

提交回复
热议问题