Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <h3>ZIPCODA Example</h3>
  <form id="fm-address">
    <div class="row section-address">
      <div class="col">
        <input id="prefecture" class="form-control" type="text" placeholder="都道府県" />
      </div>
      <div class="col">
        <input id="city" class="form-control" type="text" placeholder="市区" />
      </div>
      <div class="col">
        <input id="address" class="form-control" type="text" placeholder="住所" />
      </div>
      <div class="col">
        <input id="other" class="form-control" type="text" placeholder="建物等" />
      </div>
    </div>
    <div class="row mt-2 mb-2">
      <div class="col">
        <a id="to-zip" class="btn btn-primary" href="javascript:void(0);">住所から郵便番号へ</a>
        <a class="btn btn-secondary" id="to-addr" href="javascript:void(0);">郵便番号から住所へ</a>
      </div>
    </div>
    <div class="row section-zipcode">
      <div class="col">
        <input id="zip" class="form-control" type="text" placeholder="郵便番号" />
      </div>
    </div>
  </form>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                $(document).ready(function () {
  $("#to-zip").on("click", function () {
    const pref = $("input#prefecture").val();
    const city = $("input#city").val();
    const addr = $("input#address").val();

    const address = pref + city + addr;

    $.ajax({
      url: "https://zipcoda.net/api",
      dataType: "jsonp",
      data: {
        address: address
      }
    }).then((data) => {
      const zip = data.items[0].zipcode;
      $("input#zip").val(zip);
    });
  });

  $("#to-addr").on("click", function () {

    const zip = $("input#zip").val();

    $.ajax({
      url: "https://zipcoda.net/api",
      dataType: "jsonp",
      data: {
        zipcode: zip
      }
    }).then((data) => {
      const pref = data.items[0].components[0];
      const city = data.items[0].components[1];
      const addr = data.items[0].components[2];
      $("input#prefecture").val(pref);
      $("input#city").val(city);
      $("input#address").val(addr);
    });

  });
});

              
            
!
999px

Console