$("#testText").clone().remove('select').text() won't work as the remove method doesn't remove the elements from the jQuery object, just from the DOM. Here's how it should work:
var e = $("#testText").clone(); var select = e.find('select')[0]; e[0].removeChild(select); alert( e.text() ); On Jan 12, 3:01 pm, kazuar <kazuar...@gmail.com> wrote: > anyone? > > > > kazuar wrote: > > > hello, Im kinda new in jquery so maybe its a begginer question. > > I have a page with a div containing some text and a combobox. > > something like that > > > <div id="testText"> > > hello this is text and this is combobox > > <select><option value='1'>1</option><option value='2'>2</option><option > > value='3'>3</option></select></div> > > > I wrote a function which return the text from the div. > > > alert($('#testText').text()); > > > My problem is that the function also return the text inside the combobox. > > is there a way to filter out the combobox text? > > > the only workaround I can think of is to wrap my text in another div and > > call its text. > > This workaround will be a bit complicated for me because the text on my > > page is dynamic and it can come after the input field or before the input > > field so I just want to get the text inside the div without the input > > fields text... (This only happens with combobox). > > > tnx, > > Kazuar > > -- > View this message in > context:http://www.nabble.com/function-text%28%29-in-jquery-tp21410667s27240p... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.