販売手数料計算で販売価格のidを取得しコンソール上に反映させたいが出てこない。
リロードするとokが出る為つながっているとは思うのですがなぜかnullと出ています
ご教授お願いします
javascript
1// This file is automatically compiled by Webpack, along with any other files 2// present in this directory. You're encouraged to place your actual application logic in 3// a relevant structure within app/javascript and only use these pack files to reference 4// that code so it'll be compiled. 5 6require("@rails/ujs").start() 7require("turbolinks").start() 8require("@rails/activestorage").start() 9require("channels") 10require("packs/item_price"); 11 12 13// Uncomment to copy all static images under ../images to the output folder and reference 14// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) 15// or the `imagePath` JavaScript helper below. 16// 17// const images = require.context('../images', true) 18// const imagePath = (name) => images(name, true)
javascript
1window.addEventListener('load', () => { 2 console.log("OK"); 3}); 4 5 6const priceInput = document.getElementById("item-input"); 7console.log(priceInput);
rails
1 <%# 販売価格 %> 2 <div class="sell-price"> 3 <div class="weight-bold-text question-text"> 4 <span>販売価格<br>(¥300〜9,999,999)</span> 5 <a class="question" href="#">?</a> 6 </div> 7 <div> 8 <div class="price-content"> 9 <div class="price-text"> 10 <span>価格</span> 11 <span class="indispensable">必須</span> 12 </div> 13 <span class="sell-yen">¥</span> 14 <%= f.text_field :price, class:"price-input", id:"item-price", placeholder:"例)300" %> 15 </div> 16 <div class="price-content"> 17 <span>販売手数料 (10%)</span> 18 <span> 19 <span id='add-tax-price'></span>円 20 </span> 21 </div> 22 <div class="price-content"> 23 <span>販売利益</span> 24 <span> 25 <span id='profit'></span>円 26 </div> 27 </span> 28 </div> 29 </div> 30 <%# /販売価格 %>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/29 10:04