###■困っていること
クリックによってcssを変更したいです。
【positionの変更はOK】なのに、
同様の書き方で【padding-bottomの変更がダメ】なのです。
これはいったい、どういう理由なのでしょうか??
###■実際の動き
https://jsfiddle.net/Ltzvsk7w/
###■上のコード
【positionの変更はOK】
html
1<div id="ok"> 2<div class="okdayo" onclick="setPosition('relative');"> 3<div class="btn_ok">クリックでposition変更(absolute→relative)</div> 4</div> 5</div> 6 7<script> 8function setPosition( $position ) { 9 var $elementReference = document.getElementById( "ok" ); 10 $elementReference.style.position = $position; 11} 12</script>
【padding-bottomの変更がダメ】
html
1<div id="dame"> 2<div class="damedayo" onclick="setPadding('100px');"> 3<div class="btn_dame">クリックでpadding-bottom変更(10px→100px)</div> 4</div> 5</div> 6 7<script> 8function setPadding( $padding-bottom ) { 9 var $elementReference = document.getElementById( "dame" ); 10 $elementReference.style.padding-bottom = $padding-bottom; 11} 12</script>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/02/03 08:17
2018/02/03 11:31
退会済みユーザー
2018/02/03 16:30
2018/02/03 18:01