Home > Web Front-end > JS Tutorial > Discussion on the compatibility issues of selecting drop-down list selection items in different browsers_jquery

Discussion on the compatibility issues of selecting drop-down list selection items in different browsers_jquery

WBOY
Release: 2016-05-16 17:22:11
Original
1070 people have browsed it

I made a project using jquery to get the text of the selected item when the drop-down list selection changes. I wrote it as follows:

Copy the code The code is as follows:

$("#rd ").change(function () {
$("#name").val($("#rd").find("option:checked").text());
});

Since the browser versions of the development environment are relatively high, IE10, FF23, Chrome29, the test was all fine. After deploying it to the server, there was a problem with the customer, and the text could not be obtained. After careful testing, I found that the selected option should be selected. After changing it to selected, there is no problem with IE6, 7, 7, 8, 10, FF, and chrome.

It seems that you are still careful when writing code. Higher version browsers are compatible with some attributes, but it makes programmers lazy. Alas, there is no way!
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template