jQuery表单选择

<!DOCTYPE html>
<html>
<head>
    <title>index</title>
    <script type="text/javascript" src="jquery-3.3.1.js"></script>
    <style type="text/css">

    </style>
</head>
<body>
    <select>
          <option value="1">Flowers</option>
          <option value="2" selected="selected">Gardens</option>
          <option value="3">Trees</option>
    </select>
</body>
</html>

<script>
    $(function(){
        $("select option:selected").css({
            "border" : "2px solid red",
            "width" : "100px",
            "background-color" : "red"
        })
    })
</script>   

效果这里写图片描述

正常是看不到的,只有将下拉框展示出来后,才会看到

猜你喜欢

转载自blog.csdn.net/zs18052449719/article/details/80708725
今日推荐