Retrieve label content in Jquery -
I am using JQuery for my application. In my code, I only want to get the text of 'first name' in the label.
I have tried it with
$ ("# label" + div_id + ""). .html (); // shows the first name with the span tag.
But I just need the first name, how can I do this?
The following is my HTML code
& lt; Label id = "label1" & gt; First name & lt; Span class = "req" & gt; & Lt; Them & gt; * & Lt; / Em> & Lt; / Span & gt; & Lt; / Labels & gt;
General solution to this problem - that is, get instant text, but not a child text - elem.clone (). Children () Remove (). the ending (). Text ();
(where elem is $ ("# label" + div_id)
). Similar result is the solution of karim79, but if the other tags are not added to the label, then by the benefit of breaking it
Comments
Post a Comment