tags:

views:

41

answers:

1

I am appending a variable from an input to a li. I want to trim the P <p class="layer' + count + '"> '+ Xia2 +'</p> text to a number of 15 characters and not trim the SPAN, witch uses the same Xia2 variabile. I can probably create 2 variabiles for this...

How can this be done? I've tried several ways trying the $(this).val(text.substr(0, 5));

Here is my append code:

Xia2 = $(this).val();
$("#detailes ul").append('<li class="n' + count + '"><input class="layer' + count + '" type="checkbox"><input class="lock ' + count + '" type="checkbox"><input class="del ' + count + '" type="checkbox"><p class="layer' + count + '"> '+ Xia2 +'</p></li>');
$('<span id="layer' + count + '">'+ Xia2 +'</span>').appendTo('#selectable1');

Thank you.

+2  A: 

You are close. you should be able to use

Xia2.substring(0,15)

or

$(this).val().substring(0,15)

depending on how you want to implement it

T B
Thanx a lot your code did it!All the best!
Mircea