1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < title >Insert title here</ title > </ head > < body > < p style = "background-color: #ff0000;" >여기가 p태그</ p > < p style = "background-color: #00ff00;" >여기가 p태그</ p > < p style = "background-color: #0000ff;" >여기가 p태그</ p > < button >클릭시에 배경색을 취득</ button > < div id = "news" >로드중.....</ div > < script type = "text/javascript" > // txt 파일 가져오기 (load) $(function() { // 읽어 올 문서의 파일명 , 확인용 함수 (완료 여부) $("#news").load("news.txt", function(txt, status) { if (status == "success") { alert("로딩 성공"); alert(status); alert(txt); } else if (status == "error") { alert("로딩 실패"); } }); // 배경색 변경 $("button").click(function() { // getter // var color = $("p").css("background-color"); // alert("color = " + color); // setter // $("p").css("background-color", "#ffff00"); // 여러개 바꾸기, json 방법 $("p").css({ "background-color" : "gray", "font-size" : "200%", "border" : "solid 5px red" }); }); }); </ script > </ body > </ html > |