I'm getting a return value for this query that doesn't make sense.
code is:
var option = $(":selected").text();
result:
10 Activity
can anyone tell me why I'm getting back a 10 and spaces and how to get rid of them?
html:
<select name="datagrid_filter" onchange="startFilter(this);">
<option>All</option>
<option disabled="true">Assignment:</option>
<option disabled="true">Client:</option>
<option disabled="true">Type:</option>
<option class="type" value="Activity">   Activity</option>
<option class="type" value="Alert">   Alert</option>
<option class="type" value="Lead">   Lead</option>
<option class="type" value="Notification">   Notification</option>
</select>
You can remove unwanted spaces using the the function:
jQuery.trim( str )
regarding the "10" if you have other <select> the page, to avoid problems, refer directly to the <select name="datagrid_filter"> by name
$("select[name='datagrid_filter'] option:selected").text()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With