0

The following Snippet Code only alerts "Status = ". The code does not retrieve the value/text. Not sure what I'm doing wrong.

<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">

function getStatus() {
  var statusVal = $("select[title='Status'] option:selected").text();
  alert("Status = ",statusVal);
}

$(document).ready(function() {
  getStatus();
}); 

</script>
1
  • can you check browser console for any error ? Commented Jan 24, 2017 at 17:56

1 Answer 1

0

That isn't how alert works. It should be:

alert("Status = "+statusVal);

If you run $("select[title='Status'] option:selected").text() in the console of your browser is it returning the right value?

1
  • Thank you, the alert syntax was the issue!!! This fixed it. Commented Jan 24, 2017 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.