get selected option attribute value jquery

    It helps to user for reference of the input information or content. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. The .val() method is primarily used to get the values of form elements such as input, select and textarea. To get the value in jQuery, use the data-attributes with the data() method. An example to get the text of selected option If you want to get the text not the value of the selected option in jQuery, you can use the $.text method. Web hosting by Digital Ocean | CDN by StackPath. Get Content - text(), html(), and val() Three simple, but useful, jQuery methods for DOM manipulation are: text() - Sets or returns the text content of selected elements html() - Sets or returns the content of selected elements (including HTML markup) val() - Sets or returns the value of form fields The following example demonstrates how to get content with the jQuery text() and html() methods: The .val() method allows setting the value by passing in a function. This is useful when working on a jQuery object containing elements like , , and