waqas adil waqas adil - 2 months ago 12
jQuery Question

How to get text between <input> and <br> using jquery?

I want to get text between html tags instead of tags value.
For example:
there is a tag

<input id="item" type="checkbox" name="vehicle" value="bike" >I have a bike <br>


i just need the text
I have a bike
instead of the
value="Bike"
.

Here is my Fiddle

Options Tag text is also not getting on the item list

Thanks In Advance for your kind help. Fiddle example will be appreciated.

Answer

Try this - to get the currently selected value:

var optionText = $('select :selected').val();

To get the currently selected text:

var optionText = $('select :selected').text();