<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kikiki-kiki</author_name>
  <author_url>https://blog.hatena.ne.jp/kikiki-kiki/</author_url>
  <blog_title>かもメモ</blog_title>
  <blog_url>https://chaika.hatenablog.com/</blog_url>
  <categories>
    <anon>JavaScript</anon>
    <anon>jQuery</anon>
  </categories>
  <description>javascriptで要素についたクラスの1つめだけ取り出したい時。 element.className.split(&quot; &quot;)[0]; で最初のクラス名を取得できます。たいていjQueryを使っている思うので、 // HTML &lt;p id=&quot;hoge&quot; class=&quot;className1 className2&quot;&gt;要素だよ&lt;/p&gt; // jQuery $('#hoge').attr('class').split(&quot; &quot;)[0]; の様な記述をすることが多いんじゃないかと思います。が、ここでトラップです。 jQueryのattrを使うと、 下のように要素にクラスが無い時にだとsplitできないよ。…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fchaika.hatenablog.com%2Fentry%2F2014%2F06%2F24%2F122734&quot; title=&quot;JSで1つめのクラス名を取得する。 - かもメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-06-24 12:27:34</published>
  <title>JSで1つめのクラス名を取得する。</title>
  <type>rich</type>
  <url>https://chaika.hatenablog.com/entry/2014/06/24/122734</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
