Mahedi Sabuj Mahedi Sabuj - 2 years ago 138
Javascript Question

Get Inner Text from DIV


<div id="country">

<div id="capital">

  1. From
    , I want to get Bangladesh

  2. From
    , I want to get Dhaka

How can I achieve this?

Answer Source

Try if this works


.clone() clones the selected element.

.children() selects the children from the cloned element

.remove() removes the previously selected children

.end() selects the selected element again

.text() gets the text from the element without children

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download