2

    All I want to get only "All" without <ins>

When I use $j(this).parent().html() I get

<ins class="jstree-checkbox">&nbsp;</ins>
<ins class="jstree-icon">&nbsp;</ins>
All

but I need only "All" How can I get it ?

0

3 Answers 3

4

Assuming the .parent() part is correct, try this:

var result = $j(this).parent().contents().last().text();

You may want to trim the result, because there will likely be white space.

var result = $j(this).parent().contents().last().text();

result = $j.trim(result);

Or if there isn't any other text, you can just do this:

var result = $j(this).parent().text();
Sign up to request clarification or add additional context in comments.

2 Comments

Works with a tweak: var result = $j(this).parent().contents().last().text(); (jsfiddle.net/krLw3)
@Pat - Thanks. :o) I caught that before my last edit. In my test code I had .text() on the next line.
2

Try the following to get 'All'

obj = $(this).parent().get(0); 
var allText = obj.lastChild.nodeValue;

1 Comment

andreas - Good solution. Although if you're going to take the native API route, might as well go all the way: var allText = this.parentNode.lastChild.nodeValue; :o)
1
($j(this).parent().html().substring(78, $j(this).parent().html().length)

Any better solutions ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.