鎬庝箞瀹炵幇鍗曞嚮span鏃剁粰span娣诲姞杈规

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鎬庝箞瀹炵幇鍗曞嚮span鏃剁粰span娣诲姞杈规相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/string' title='string'>string   http   oev   abs   attr   eve   cursor   event   asp.net   

璇存槑锛?/span>

      1銆佸紑鍙戠幆澧?vs2012 asp.net mvc4 c#

1銆佹晥鏋滃浘

鎶€鏈垎浜浘鐗? src=

2銆乭tml 鍓嶇浠g爜

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="MvcAppTest.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="ewJS/jquery.js"></script>
    <style type="text/css">
           .SelectItem {
            border:1px solid red;
        }
   .UNSelectItem {
        /*border:none;*/
        border:1px solid #73b2ff;
        }
      .resultHTML
        {
            width:370px;
            height:200px;
            float:left;
            background-color:#73b2ff;
            color:white;        
            z-index:1001;
            position:absolute;
            display:none;
            padding:10px 0px 0px 10px;
        }
         .span1
      {
       width:60px;
       font-size:18px;
       
       line-height:32px;
       height:32px;
       cursor:pointer;
       }
    </style>
    <script type="text/javascript">
        var countItem = 1;
        $(function () {
            test02();
            $(".span1").hover(function () {
                //var test3 = $("#span01").text();
                if (countItem>1) {
                    var display = $(鈥?/span>#resultHTML鈥?/span>).css(鈥?/span>display鈥?/span>);
                    if(display == 鈥?/span>none鈥?/span>) {
                        $("#resultHTML").css(鈥?/span>display鈥?/span>, 鈥?/span>block鈥?/span>);
                    }
                }
                else {
                    console.log(鈥?/span>涓嶆槸鏌愭煇甯?/span>鈥?/span>);
                }

            }, function () {

            });
            $(鈥?/span>#resultHTML鈥?/span>).hover(function () { }, function () {
                var display = $(鈥?/span>#resultHTML鈥?/span>).css(鈥?/span>display鈥?/span>);
                if (display == 鈥?/span>block鈥?/span>) {
                    $("#resultHTML").css(鈥?/span>display鈥?/span>, 鈥?/span>none鈥?/span>);
                }
            });

        });
        function test02() {
            var userName = 鈥?/span>1鈥?/span>;
         
      
            var IsCity = false;
            var IsQu = false;
            var userData = { username: 鈥?/span>100鈥?/span>, pwd: 鈥?/span>888888鈥?/span>, officeID: -1 };//涓€瀹氳鍐欏湪澶栭潰
            $.ajax({
                type: 鈥?/span>post鈥?/span>,
                url: 鈥?/span>Home/Getdata鈥?/span>,
                dataType: 鈥?/span>json鈥?/span>,
                data: userData,
                success: function (result) {
                    if (result.length > 1) {
                        countItem = result.length;
                    };
                    var str = "<div>";
                    var item1 = "<div id=鈥榙ivCity鈥?style=鈥榤argin-bottom:5px;鈥?gt;";
                    if (userName == "1") {
                        item1 += 鈥?/span><span area="0" id="鈥?/span> + -1 + 鈥?/span>"  style=" font-size:16px;font-weight:bold;cursor:pointer;" onclick="test03(鈥?/span> + -1 + 鈥?/span>, 鈥?/span> + 鈥?/span>鈥樻煇鏌愬競鈥?/span>鈥?/span> + 鈥?/span>)" >鈥?/span> + 鈥?/span>鏌愭煇甯?/span>鈥?/span> + 鈥?/span></span>鈥?/span>;
                        IsCity = true;
                    }
                    item1 += "</div>";
                    str += item1;
                    var item2 = "<div id=鈥榙ivTown鈥?style=鈥榝ont-size:14px;鈥?gt;";
                    $.each(result, function (i, value) {
                        //if (value.IsALL != 1) {
                        item2 += 鈥?/span><span area="鈥?/span> + value.MapId + 鈥?/span>" id="鈥?/span> + value.id + 鈥?/span>" style="cursor:pointer;line-height:25px;display:block;float:left;margin-right:20px;" onclick="test03(鈥?/span> + value.id + 鈥?/span>,鈥?/span> + 鈥?/span>鈥?/span>鈥?/span> + value.Name + 鈥?/span>鈥?/span>鈥?/span> + 鈥?/span>)">鈥?/span> + value.Name + "</span>";
                        //}
                    });
                    item2 += "</div>";
                    str += item2;
                    str += "</div>";
                    $("#resultHTML").append(str);
                    if (result.length != 1) {
                        test03(鈥?/span>-1鈥?/span>);
                        $(鈥?/span>#span01鈥?/span>).html(鈥?/span><span style="height:31px;line-height:31px;font-size:18px;">鏌愭煇甯?lt;/span>鈥?/span>);
                    }
                    else {
                        $(鈥?/span>#dsj鈥?/span>).hide();
                        test03(result[0].id);
                        $(鈥?/span>#span01鈥?/span>).html(鈥?/span><span style="height:31px;line-height:31px;font-size:18px;">鈥?/span> + result[0].Name + 鈥?/span></span>鈥?/span>);
                    }
                },
                error: function (ex) {
                    //debugger;
                    // alert(鈥榚rror鈥?;
                    Console.log("Getdata鏂规硶鎵ц閿欒" + ex);
                }
            });
        }
        function test03(officeID, OfficeName) {
    
            $(鈥?/span>#span01鈥?/span>).html(鈥?/span><span style="height:31px;line-height:31px;font-size:18px;">鈥?/span> + OfficeName + 鈥?/span></span>鈥?/span>);
            var ItemDiv = document.getElementsByTagName("span");
            $.each(ItemDiv, function (i, value) {
                if (ItemDiv[i] != null) {
                    if (ItemDiv[i].getAttribute("id") != null) {
                        ItemDiv[i].className = "UNSelectItem";
                    }
                }
            });
            var selectedModel = document.getElementById(officeID);
            selectedModel.className = 鈥?/span>SelectItem鈥?/span>;
     
        }
    </script>
</head>
<body>
      <div style="width:400px;height:31px;margin-bottom:10px;background-color:#73b2ff;color:white;line-height:31px;">
      <span id="span01" class="span1">鏌愭煇甯?span style="color: #0000ff;"></span><img id="dsj" style="margin-left:10px;" src="img/dsj.png" />
      </div>
    <div id="resultHTML" class="resultHTML"></div>
</body>
</html>

3銆丠ome鎺у埗鍣?鍚庡彴浠g爜

       [HttpPost]
        public JsonResult Getdata(string username, string pwd, string officeID)
        {
            int officeId = Convert.ToInt32(officeID);
            int data1 = Convert.ToInt32(username);
            List<townModel> myList = new List<townModel>();
            for (int i = 1; i < 30;i++ )
            {
               townModel model= new townModel();
               model.id = i;
               model.IsALL = i + 1;
               model.MapId = "100" + i.ToString();
               model.Name = "涔¢晣"+i.ToString();
               myList.Add(model);

            }
            return Json(myList, JsonRequestBehavior.DenyGet);

        }
  public class townModel
    {
        public Int32 id { get; set; }
        public string Name { get; set; }
        public Int32 IsALL { get; set; }
        public string MapId { get; set; }
    }

4銆佺澶村浘鐗?/span>

鎶€鏈垎浜浘鐗? src=

5銆佹枃浠朵笅杞?/span>

閾炬帴锛歨ttps://pan.baidu.com/s/1m5zayibZnIYCARTKJ65rjQ
鎻愬彇鐮侊細15nl

 

以上是关于鎬庝箞瀹炵幇鍗曞嚮span鏃剁粰span娣诲姞杈规的主要内容,如果未能解决你的问题,请参考以下文章

Android 鑷畾涔塋istView鍗曞嚮浜嬩欢澶辨晥

鎬庝箞鐞嗚В鈥滈潪瀵圭О鍔犲瘑鈥濓紵

銆愭暟鎹粨鏋勩€戝崄澶ф帓搴忕畻娉曗€斺€?C++瀹炵幇

鎬庝箞鐢ˋPI缃戝叧鏋勫缓寰湇鍔★綔鏋舵瀯

Redis 绉掓潃瀹炴垬