Elliot
Elliot

Reputation: 13835

Jquery animation based on matching strings on page load

I have the following code

    $('.rsName').ready(if{($('.companyName').html() == $(this).html()){
        $(this).siblings(".rsDistribution").slideDown('slow', function() {});
    });

What I'm trying to do, is check if rsName and companyName are equal. If they are equal, I'd like to slide down the .rsDistribution which is a sibling div of rsName.

Any ideas why this isn't working?

Upvotes: 0

Views: 34

Answers (1)

Adam Rackis
Adam Rackis

Reputation: 83356

You had an incorrect opening brace

$('.rsName').ready(if { <-----

Also, you need to pass a function to the ready handler, which is customarily written:

$(function() {

 $(function() { 
     if($('.companyName').html() === $('.rsName').html())
        $('.rsName').siblings(".rsDistribution").slideDown('slow');
 });

I also took out the callback, since you weren't doing anything with it.

EDIT

$(function() { 
     $(".rsName").each(function(index, el) {
        if($('.companyName').html() === $(el).html())
           $(el).siblings(".rsDistribution").slideDown('slow');
     }
 });

Upvotes: 1

Related Questions