0

so I have this function below...

<script>          
$('.tile').on('click', function () {

    $(".tile").addClass("flipOutX");
    setTimeout(function(){
        $(".tile-group.six").load("musability-musictherapy-company-overview.html");
    }, 2000);

});
</script>

I basically want to change the css attributes of tile-group.six to have a different margin. Any ideas how I might go about this ?

1

2 Answers 2

4

you should take a look at the .css() function of jQuery like

$(".tile-group.six").css('margin-left', '50px');

and so on

Sign up to request clarification or add additional context in comments.

4 Comments

worked well thanks , the above answer used a slightly different syntax any ideas which one is better any why ?
Callum's answer allows you to set more than one CSS value at once: $(selector).css({ cssKeyA: 'cssValueA', cssKeyB: 'cccValueB', ... });, rather than $(selector).css('cssKeyA', 'cssValueA').css('cssKeyB', 'cssValueB');.
ah right , I think I will use that one in this instance thanks for your help buddy !
this didnt seem to work - $(".tile-group.main").css({ margin-left:"50px", width: "1080px"}).load("musability-musictherapy-company-overview.html");
3
$(".tile-group.six").css({margin:"0"});

This should be what you're after.

As Phylogenesis pointed out in his comment on the below answer, this method can be used to change multiple CSS values at once using a comma delimiter e.g.

$(".tile-group.six").css({margin:"0", padding:"0"});

5 Comments

this didnt seem to work - $(".tile-group.main").css({ margin-left:"50px", width: "1080px"}).load("musability-musictherapy-company-overview.html");
the function doesn't run at all
Okay, change margin-left to marginLeft and that should work
ok stupid me missing the uppercase on the L for left.... it works awesome, your a genius thanks ... why the different name references then ? i am guessing javascript reads a - as something else
I think it is to do with the hyphen yes, another one off the top of my head is backgroundColor, which would be background-color or simply background in a style sheet :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.