19 March 2020

How to get Selected Option Text of HTML SELECT using jQuery?

Get Selected Option Text of HTML SELECT using jQuery


<select id="mySelect">
    <option value="1">hello</option>
    <option value="2">bro</option>
</select>
<input type="button" id="test" value = "test" />
<script type="text/javascript">
    $("#test").live("click"function () {
        
        var selectedText = $("#mySelect option:selected").html();
        alert(selectedText);
    });
</script>

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...