[기초] 자바스크립트 innerHTML 을 이용한 H1~H5 자동입력
2017.05.17 12:40
346
0
https://eond.com/389504
object(HotopayModel)#814 (23) { ["error"]=> int(0) ["message"]=> string(7) "success" ["variables"]=> array(0) { } ["httpStatusCode"]=> int(200) ["module"]=> string(7) "hotopay" ["module_info"]=> NULL ["origin_module_info"]=> NULL ["module_config"]=> NULL ["module_path"]=> string(52) "/home/eond/web/eond.com/public_html/modules/hotopay/" ["xml_info"]=> NULL ["module_srl"]=> NULL ["mid"]=> NULL ["act"]=> NULL ["template_path"]=> NULL ["template_file"]=> NULL ["layout_path"]=> NULL ["layout_file"]=> NULL ["edited_layout_file"]=> NULL ["stop_proc"]=> bool(false) ["user"]=> object(Rhymix\Framework\Helpers\SessionHelper)#813 (20) { ["member_srl"]=> int(0) ["user_id"]=> NULL ["user_name"]=> NULL ["nick_name"]=> NULL ["email_address"]=> NULL ["phone_number"]=> NULL ["homepage"]=> NULL ["blog"]=> NULL ["birthday"]=> NULL ["denied"]=> NULL ["status"]=> NULL ["is_admin"]=> string(1) "N" ["is_site_admin"]=> NULL ["profile_image"]=> NULL ["image_name"]=> NULL ["image_mark"]=> NULL ["signature"]=> NULL ["description"]=> NULL ["group_list"]=> array(0) { } ["menu_list"]=> array(0) { } } ["request"]=> object(Rhymix\Framework\Request)#10 (13) { ["method"]=> string(3) "GET" ["compat_method"]=> string(3) "GET" ["url"]=> string(32) "javascript/389504/comment/464709" ["hostname"]=> string(8) "eond.com" ["domain"]=> NULL ["protocol"]=> string(5) "https" ["callback_function"]=> string(0) "" ["_route_status":protected]=> int(200) ["_route_options":protected]=> object(stdClass)#11 (5) { ["cache_control"]=> bool(true) ["check_csrf"]=> bool(true) ["is_forwarded"]=> bool(false) ["is_indexable"]=> bool(true) ["enable_session"]=> bool(true) } ["module"]=> string(5) "board" ["mid"]=> string(10) "javascript" ["act"]=> string(16) "dispBoardContent" ["args"]=> array(5) { ["category"]=> string(6) "361461" ["document_srl"]=> string(6) "389504" ["comment_srl"]=> string(6) "464709" ["mid"]=> string(10) "javascript" ["act"]=> string(16) "dispBoardContent" } } ["ajaxRequestMethod"]=> array(2) { [0]=> string(6) "XMLRPC" [1]=> string(4) "JSON" } ["gzhandler_enable"]=> bool(true) }

HTML

<div id="a">h1</div>
<div id="b"><input type="text" /></div>

CSS

input{display:block;border:0;border-bottom:1px solid #ddd;line-height:2em;padding:0 10px;margin-bottom:10px;}
.h1{font-size:2em}
.h2{font-size:1.5em}
.h3{font-size:1.17em}
.h4{font-size:1em}
.h5{font-size:0.84em}

JAVASCRIPT

var sum ='';
for(var i = 1 ; i <= 5 ; i++){
  //i = i.toString();
  var k ='<h'+i+'>내가 원하는 건 h'+i+'</h'+i+'>';
  sum+=k;
}

document.getElementById('a').innerHTML= '결과물<hr>'+sum

//
var sum ='';
for(var i = 1 ; i <= 5 ; i++){
  //i = i.toString();
  var k ='h'+i+'<input type="text" class="h'+i+'" placeholder="제목을 입력해주세요">';
  sum+=k;
}

document.getElementById('b').innerHTML= '결과물<hr>'+sum

라이믹스는 이온디와 함께

닫기

마이페이지

로그인을 해주세요

네이버로 로그인