Retrieve label content in Jquery

jquery

Solution

The general solution to this problem -- namely, getting immediate text but not child text -- is `elem.clone().children().remove().end().text();` (where elem here is `$("#label"+div_id)`). This has the same result as karim79's solution but with the benefit of not breaking if other tags are added to the label.

Problem

I am using JQuery for my application. In my code, I want to get only the text 'Firstname' in the label. I tried it with ``` $("#label"+div_id+"").html(); //but displays Firstname along with the span tag.. ``` But I only need Firstname. How can i do so? The following is my Html code ``` <label id="label1">Firstname<span class="req"><em> * </em></span></label> ```

Original source