jQuery get value within child div

后端 未结 8 1785
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 01:50

I need to grab the text value of a child div.

A
B
8条回答
  •  甜味超标
    2021-02-04 02:53

    Simple,

    var text_val = $('#second_child').text();
    

    Or your change,

    var text_val = $('#first').children('#second_child').text();
    

    This will return "B" from div of id "second_child"

    UPDATE Changed the second solution to children() instead of nextAll().

提交回复
热议问题