JQuery get content of span

后端 未结 6 1721
萌比男神i
萌比男神i 2021-02-19 00:29

I\'m trying to get the content of a span when a button is clicked. This is the html:

6条回答
  •  春和景丽
    2021-02-19 01:09

    It's not button's parent. div is button's parent and span is children of the div. Try

    var span_val = $(this).parent().children("span").html();
    

    instead.

    Working demo

提交回复
热议问题