Using jquery to determine selected option causes “specified attribute is deprecated” warning

南楼画角 提交于 2019-11-27 21:53:33

jquery is referencing the "specified" property on an Attr object, this is depreciated with Firefox 7, and always returns true. see https://developer.mozilla.org/En/DOM/Attr

i've raised a jquery ticket for this: http://bugs.jquery.com/ticket/11397

$(document).on('change','select#FIELD_NAME', function() {
    alert('your selection was: '+$('select#FIELD_NAME').attr('value'));
    return false;
});

K.I.S.S. ...whenever it's possible ;-)

Ask the select tag for it's value, it knows which one is selected and will use that tag for it's current value.

$('#testSelect').val()

Check it: http://jsfiddle.net/Ndzvm/1/

Sometimes it's simpler than you think it is :)

can you use this code

<script type="text/javascript">
$(document).ready(function() {
$('select[id$=<%=DropDownList1.ClientID%>]').bind("keyup
change", function() {
if ($(this).val() != "")
$('#message').text("Text: " + $(this).
find(":selected").text()
+ ' Value: ' + $(this).val());
else
$('#message').text("");
});
});
</script>

If the id #testSelect is your select name.

Get the value:

var selectedValue=$('#testSelect').attr('value');

Set the select value:

$('#testSelect').attr('value',your value);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!