0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

jQueryとfind()とcss()

Posted at

たとえばjQueryを使ってeach()とfind()を使って「.mc-movBox_mov_Item」を取得した場合

<div id="mov1" class="mc-movBox">
    <div class="mc-movBox_Inner">
        <div class="mc-movBox_mov">
            <div class="mc-movBox_mov_Item">あああ</div>
            <div class="mc-movBox_mov_Item">いいい</div>
            <div class="mc-movBox_mov_Item">ううう</div>
            <div class="mc-movBox_mov_Item">えええ</div>
            <div class="mc-movBox_mov_Item">おおお</div>
        </div>
    </div>
</div>
$('.mc-movBox').each(function(){
  el = $(this);
  boxes = el.find('.mc-movBox_mov_Item');
});

みたいな感じになるかと思います。
console.log()を使うと配列みたいに格納されているので思わず

boxes[0].css('visibility', 'hidden');

とかすると怒られました。
正しくは

boxes.eq(0).css('visibility', 'hidden');

eq()で指定しないとダメ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?