jQuery操作コンテンツ

<!DOCTYPE html > 
< html > 
    < head > 
        < meta charset = "utf-8" > 
        < title > </ title > 
    </ head > 
    < body > 
        < div id = "d1" > 
            < p >哈哈</ p > 
        < / div > 
        < input id = "input1" type = "text" value = "嘎嘎"  />
        type = "button" value = "点击"  /> 
        < スクリプトタイプ= "text / javascript" src = "../ images / jquery-3.4.1.min.js" > </ スクリプト> 
        < スクリプトタイプ= "テキスト/ javascript " > 
            var dj = document.getElementById(" dj " ); 
            dj.onclick =  function (){
                 / * document.getElementById( "d1")。innerHTML * / 
                / * htmlのパラメーターは使用するために修正されます* / 
                / * var html = $( "* / 
                var html = $(" #d1 " ).html(); // <p>哈哈</ p> 
                alert(" html:" + html);
                / * document.getElementById( "d1")。innerText * / 
                var text = $(" #d1 " . text (); // 哈哈
                alert(" text:" + text);
                / * document.getElementById( "d1")。
                #d1 " ).val(); // 空の
                アラート(" val:" + val);
                 / * css(properties):Set a" name:value "object to all matching element style properties * / 
                $(" # d1 " ).css({width:" 100px " 、height:" 100px " 、color:" red " });
                 / * 属性名は次を含みます-引用符を使用する必要があります* / 
                $(" #d1 " ).css({ マージントップ" 200px" }); 
                
            } 
        </ script > 
    </ body > 
</ html >

 

おすすめ

転載: www.cnblogs.com/qilin20/p/12669362.html