20200624のHTMLに関する記事は9件です。

【jQuery】手数料を計算して表示させたい

ユーザーが入力した数値に計算を加えて表示させる際の手順について
簡潔にまとめたのでご紹介します。
(今回は、価格と販売利益として表示します。)

1. HTMLで価格コーナーを準備する

sample.haml
~省略~

= f.number_field :price, placeholder: "0", class: 'exhibit-form_price' do -#入力欄
  %span.mark
    ¥
   .exhibit-form_right
.commission-line
  .commission-line_left
    販売手数料 (10%)
  .commission-line_right.profit-line
    .profit-line_left
      販売利益
    .profit-line_right
       ー

~省略~

2. Jsの準備をする

フォームの入力値を取得し、任意の計算をした数値を
販売利益の欄に差し込みます。

sample.js
  $('.exhibit-form_price').on('keyup', function(){
    var data = $(this).val();
    var profit = Math.round(data * 0.9)
    var fee = (data - profit)
    $('.commission-line_right').html(fee)
    $('.commission-line_right').prepend('¥')
    $('.profit-line_right').html(profit)
    $('.profit-line_right').prepend('¥')
    $('#price').val(profit)
    if(profit == '') {
    $('.profit-line_right').html('');
    $('.commission-line_right').html('');
    }
  })

以上で終了です。
ご覧いただきありがとうございました。

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

WATCH!!..Sheffield United vs Man United LivE StreaM

Man United vs Sheffield United Live Stream: How and Where to watch online.  Manchester United host Sheffield United in the Premier League tonight.

Man united vs sheffield united.jpg

Bruno Fernandes was United's hero once again on Friday with his late penalty earning a share of the points at Tottenham Hotspur.

Paul Pogba returned in the second-half in north London and could get his first start of Project Restart this evening.

The Blades are yet to win since the league's resumption and followed up an opening draw with Aston Villa with a deeply disappointing 3-0 defeat at Newcastle on Sunday.

When is it and what time is kick-off?
The match will begin at 6 pm on Tuesday 23 June at Old Trafford.

How can I watch it online and on TV?

Date: Wednesday, June 24
Time: 1 pm ET
Location: Old Trafford --Manchester, England
TV: NBCSN and Universo
Live stream: fuboTV (Try for free)
Odds: Man. United -245; Draw +330; Sheffield United +800 (via William Hill Sportsbook)

The match will be broadcast live on Sky One, Sky Sports Premier League, Sky Sports Main Event, and Pick. To watch the match without a Sky Sports subscription, you can purchase a Now TV pass here.

Predicted line-ups
Manchester United: De Gea, Wan-Bissaka, Lindelof, Maguire, Shaw, Pogba, McTominay, Fernandes, James, Rashford, Martial

Sheffield United: Moore, Basham, O'Connell, Robinson, Baldock, Berge, Norwood, Lundstram, Stevens, Sharp, McBurnie

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

StreaminG!..Aston Villa vs Newcastle Live Stream

Newcastle vs Aston Villa: TV Channel, Live Stream, EPL Soccer Match Today.  Aston Villa travels to Newcastle this evening as they continue their attempt to escape the Premier League relegation zone.

newcastle vs aston villa.jpg

While Newcastle defeated a 10-man Sheffield United 3-0 in their last outing, Villa followed a 0-0 draw against the Blades with a 2-1 defeat by Chelsea.

Dean Smith's Villa sit 19th in the table on 26 points with time running out, communicating the Magpies are 13th on 38 points with a top-half finish not out of the question.

When is it and what time is kick-off?
The match will begin at 6 pm on Wednesday 24 June at St James' Park.

How can I watch it online and on TV?

Who: Newcastle United vs. Aston Villa
When: Wednesday at 1 pm ET
Where: St. James' Park
TV: NBCSportsGold.com PL Pass
Online streaming: Catch select Premier League matches on fuboTV (Try for free. Regional restrictions may apply.)
Follow: CBS Sports App

The match will be broadcast live on BT Sport 1, with coverage beginning at 5.45 pm. BT Sport subscribers can also stream the game on the BT Sport app.

Newcastle United's win lifted them to 10-12-8 (13th place with 38 points) while Aston Villa's defeat dropped them down to 7-18-5 (19th place with 26 points). We'll see if the Magpies can repeat their recent success or if Villa bounces back and reverse their fortune.

Predicted line-ups
Newcastle: Dubravka; Manquillo, Lascelles, Fernandez, Rose; Ritchie, Hayden, Shelvey, Saint-Maximin, Almiron; Joelinton

Aston Villa: Nyland; Konsa, Hause, Mings, Targett; Douglas Luiz, Grealish, Hourihane; El Ghazi, Samatta, Trezeguet

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Live...Everton vs Norwich City Live Stream

Norwich City vs Everton: TV Channel, Live Stream, EPL Today Football Match.  Everton travels to Norwich City for both teams' second match back after the resumption of the Premier League season.

Norwich City vs Everton.jpg

Norwich suffered a 3-0 loss against Southampton over the weekend, while Everton drew 0-0 at home to Liverpool.

Both sides will be hoping they can make a return the scoresheet this time around, with Norwich aiming to reduce the six-point gap between themselves and safety and Everton aiming for a top-half finish.

When is it and what time is kick-off?
The match will begin at 6 pm on Wednesday, 24 June at Carrow Road.

How can I watch it live stream and on TV?

Who: Norwich City vs. Everton
When: Wednesday at 1 pm ET
Where: Carrow Road
TV: NBCSportsGold.com PL Pass
Online streaming: Catch select Premier League matches on fuboTV (Try for free. Regional restrictions may apply.)
Follow: CBS Sports App

The match will be broadcast live on BBC Two (first half), BBC One (second half), and the BBC iPlayer.

What is the team news?
Norwich will have Marco Stiepermann available again after having tested positive for Covid-19 earlier in the month. There were no injuries for Norwich in their last game so it should be a near-full squad for Farke.

Everton is still without Yerry Mina, Fabian Delph, and Theo Walcott, while Morgan Schneiderlin has been sold to Nice. Djibril Sidibe is unlikely to be fit in time for this game.

Predicted line-ups
Norwich: Krul; Aarons, Godfrey, Klose, Lewis; McLean, Tettey; Buendia, Cantwell, Duda; Pukki.

Everton: Pickford; Coleman, Holgate, Keane, Digne; Iwobi, Davies, Gomes, Bernard; Calvert-Lewin, Richarlison.

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Atomの色が消える

Atomで色が消えてしまう。。。

「Atom」→「環境設定」→「コア設定」→「Use Tree Sitter Parsers」のチェックを外すと直りました。

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

<a>タグのリンクを無効化するには?

aタグにはdisable属性がない

Chromeの場合、<input> <textarea> <select>タグなどはdisabledを書けば非活性になりますが、<a>タグにはdisable属性がないので利きません。

aタグのリンクを無効化するには?

css
 pointer-events:none;

上記で非活性化することができます。
<img>タグも同様です。

ある条件のときだけ複数の項目を一括で非活性にするには?

そういう場合はJavaScriptを使います。
変更したい項目を<div>で囲み、idを付与します。

タグ名で要素を指定することで、項目を複数取得することが出来ます。
【document.getElementById("ID名").getElementsByTagName("input")

それをFor文で回して各項目ごとにdisable属性や、css.Style属性を付与していきます。

JavaScript
window.onload = function(){
    var flg = $("#modeflg").val();
/*条件*/
    if(flg == "2"){     
        var inputItem = document.getElementById("changeDisable").getElementsByTagName("input");
        for(var i=0; i<inputItem.length; i++){
          inputItem[i].disabled = true;
        }
        var inputItem = document.getElementById("changeDisable").getElementsByTagName("textarea");
        for(var i=0; i<inputItem.length; i++){
          inputItem[i].disabled = true;
        }
        var selectItem = document.getElementById("changeDisable").getElementsByTagName("select");
        for(var i=0; i<selectItem.length; i++){
          selectItem[i].disabled = true;
        }
        var selectItem = document.getElementById("changeDisable").getElementsByTagName("a");
        for(var i=0; i<selectItem.length; i++){
            selectItem[i].style.pointerEvents = 'none';
        }
        var selectItem = document.getElementById("changeDisable").getElementsByTagName("img");
        for(var i=0; i<selectItem.length; i++){
            selectItem[i].style.pointerEvents = 'none';
        }
    }
};

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【初心者でもわかる】CSSのセレクタ3種類の書き方

【初心者でもわかる】CSSのセレクタ3種類の書き方(隣接セレクタ・間接セレクタ・直下セレクタ)

セレクタは、どの対象にCSSを適用させるかを指示するもの。
「セレクタって何?」という方、近日中にセレクタについての記事もかきますのでお待ちくださいませ!

『隣接セレクタ』(+)

次の兄弟要素、つまりある要素から見て同階層にある次の要素に対してCSSを適用することができます。

隣接セレクタの書き方

See the Pen 隣接セレクタ by 7note (@7note) on CodePen.

隣接セレクタの書き方は、【+】(プラス)を使います。
h2には「h1の次にくるh2を赤色に」という書き方をしています。
同様に、h3には「h2の次にくるh3を青色に」という書き方をしています。

※注意として隣接セレクタは名前の通り隣にいないとCSSが適用されません!
(なので、h4には緑色が反映されていません。隣接セレクタを使ってh4にCSSを当てたいなら「h1 + h4」となっているところを、「h3 + h4」と書きましょう!)

『間接セレクタ』(~)

以降の兄弟要素全て、つまりある要素から見て同階層にいるそれ以降の要素全てに対してCSSを適用することができます。

間接セレクタの書き方はこちら↓

See the Pen 間接セレクタ by 7note (@7note) on CodePen.

間接セレクタの書き方は、【~】(チルダ)を使います。
h2には「同階層にあるh1以降の全てのh2を赤色に」という書き方をしています。
h3には「同階層にあるh2以降の全てのh3を青色に」という書き方をしています。
さきほどはh4には緑色が入りませんでしたが「同階層にあるh1以降の全てのh4を青色に」という書き方になるので、h4にも緑色が適応されました。

『直下セレクタ』(>)

直属の子要素にのみ、CSSを適用することができます。

直下セレクタの書き方はこちら↓

See the Pen mdVmxXz by 7note (@7note) on CodePen.

直下セレクタの書き方は、【>】(大なり)を使います。
下線「japanとついたクラスの中にある全てのp」に対して適応されていますが、
赤色「japanとついたクラスから見て、1つ中の階層にあるp」にだけ適応されています。

まとめ

セレクタの種類 使う記号 適応範囲
隣接セレクタ + 同階層にある次の要素
間接セレクタ ~ ある要素から見て同階層にいるそれ以降の要素
直下セレクタ > 直属の子要素
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【初心者でもわかる】CSSのセレクタ3種類の書き方(隣接セレクタ・間接セレクタ・直下セレクタ)

どうも、7noteです。今回はセレクタのお話。

セレクタは、どの対象にCSSを適用させるかを指示するもの。
「セレクタって何?」という方、近日中にセレクタについての記事もかきますのでお待ちくださいませ!

『隣接セレクタ』(+)

次の兄弟要素、つまりある要素から見て同階層にある次の要素に対してCSSを適用することができます。

隣接セレクタの書き方

See the Pen 隣接セレクタ by 7note (@7note) on CodePen.

隣接セレクタの書き方は、【+】(プラス)を使います。
h2には「h1の次にくるh2を赤色に」という書き方をしています。
同様に、h3には「h2の次にくるh3を青色に」という書き方をしています。

※注意として隣接セレクタは名前の通り隣にいないとCSSが適用されません!
(なので、h4には緑色が反映されていません。隣接セレクタを使ってh4にCSSを当てたいなら「h1 + h4」となっているところを、「h3 + h4」と書きましょう!)

『間接セレクタ』(~)

以降の兄弟要素全て、つまりある要素から見て同階層にいるそれ以降の要素全てに対してCSSを適用することができます。

間接セレクタの書き方はこちら↓

See the Pen 間接セレクタ by 7note (@7note) on CodePen.

間接セレクタの書き方は、【~】(チルダ)を使います。
h2には「同階層にあるh1以降の全てのh2を赤色に」という書き方をしています。
h3には「同階層にあるh2以降の全てのh3を青色に」という書き方をしています。
さきほどはh4には緑色が入りませんでしたが「同階層にあるh1以降の全てのh4を青色に」という書き方になるので、h4にも緑色が適応されました。

『直下セレクタ』(>)

直属の子要素にのみ、CSSを適用することができます。

直下セレクタの書き方はこちら↓

See the Pen mdVmxXz by 7note (@7note) on CodePen.

直下セレクタの書き方は、【>】(大なり)を使います。
下線「japanとついたクラスの中にある全てのp」に対して適応されていますが、
赤色「japanとついたクラスから見て、1つ中の階層にあるp」にだけ適応されています。

まとめ

セレクタの種類 使う記号 適応範囲
隣接セレクタ + 同階層にある次の要素
間接セレクタ ~ ある要素から見て同階層にいるそれ以降の要素
直下セレクタ > 直属の子要素
おしまい。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

学習記録4日目(2020/6/23)

学習内容

  • HTML&CSS学習(Progate)

その他

  • タイピング練習

明日の予定

 HTML&CSSの基礎は大体問題なさそうなので明日で道場編を一通り行い、次に移りたいと思います。

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む