Farok Ojil Farok Ojil - 3 months ago 9x
jQuery Question

jquery - get text for element without children text

for example we have this file

<div id="mydiv">
some text here
<div id="inner div">
text for inner div

i need to get
text only with some code like this :

alert($('#mydiv').text()); // will alert "some text here"


hey try this please": http://jsfiddle.net/MtVxx/2/

Good link for your specific case in here: http://viralpatel.net/blogs/jquery-get-text-element-without-child-element/ (This will only get the text of the element)

Hope this helps, :)


jQuery.fn.justtext = function() {

    return $(this).clone()