How do I get a value of a using jQuery?

后端 未结 12 1426
青春惊慌失措
青春惊慌失措 2020-11-28 07:53

This is basic.

How do I get the value \'This is my name\' of the above span?

This is my name
12条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 08:23

    VERY IMPORTANT Additional info on difference between .text() and .html():

    If your selector selects more than one item, e.g you have two spans like so bar1 bar2 ,

    then

    $('.foo').text(); appends the two texts and give you that; whereas

    $('.foo').html(); gives you only one of those.

提交回复
热议问题