欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用jQuery獲得內(nèi)容以及內(nèi)容的屬性

 更新時(shí)間:2015年02月26日 10:58:09   投稿:hebedich  
本文給大家分享的是一則使用jQuery獲得內(nèi)容以及內(nèi)容的屬性的方法和示例,非常實(shí)用,推薦給大家。

復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="js/jquery.js"></script>
    </head>
<style>
body{font-family: "微軟雅黑";width: 980px; margin: 0 auto; text-align: center;}
    .box{
        width: 300px;
        height: 300px;
        background: green;
        border: 1px solid #e6e6e6;
        line-height: 200px;
        position: absolute;
    }
button{
    border: none;
    background: green;   
    width: 125px;
    height: 50px;
    line-height: 50px;
    color: #fff;
    font-size: 16px;
    margin-top: 50px;
    font-family: "微軟雅黑";
    }
</style>
    <body>
        <button id="btn1">顯示text</button>
        <button id="btn2">顯示html</button>
        <button id="btn3">顯示輸入內(nèi)容</button>
        <p id="text">這是要顯示<b>粗體</b>的節(jié)奏</p>
        <br />
        <input id="input" value="買房子">
        <script>
            $(document).ready(function(){
                $("#btn1").click(function(){
                    alert("Text: " + $("#text").text());
                });
                $("#btn2").click(function(){
                    alert("HTML: " + $("#text").html());
                });
                $("#btn3").click(function(){
                    alert("Value: " +$("#input").val());
                });
            });
        </script>
    </body>
</html>

Tips:

1、點(diǎn)擊事件節(jié)點(diǎn)的選擇 #botton

2、alert 的代碼規(guī)則  ("Value: " + $("#id").html)

今天的分享就先到這里了,后續(xù)我們還將持續(xù)更新一些新的jQuery實(shí)例。

相關(guān)文章

最新評論