0

In a Meteor application, I have this on the client side:

Meteor.startup(function() {
    Deps.autorun(function () {
        var p = Session.get("page");
        if(!!Session.get(p)) {
            _.map(pages, function(p) {
                $("." + p).children().remove();
            });
            $("." + p).append(Session.get(p));
            // Assign h2-link to h2's that contain an a
            // to customize their appearance in CSS
            $("a").parent("h2").addClass("h2-link");
        }
    });
});

The above code removes HTML from all dummy classes and appends a customized HTML snippet to the active one.

$("a").parent("h2").addClass("h2-link"); applies a custom style to h2s that contain a link.

Now, having defined h2-link in CSS to be .h2-link { border-bottom: 1px solid red; } works perfectly.

Doing it directly via $("a").parent("h2").css("border-bottom: 1px solid red;"); does not work.

Why doesn't it work when I try to apply styles directly on the DOM?

Does Meteor prohibit DOM-CSS-applications?

1 Answer 1

3

Try this

$("a").parent("h2").css("border-bottom", "1px solid red")
Sign up to request clarification or add additional context in comments.

1 Comment

Haha, that was an easy one. I was so confident that I knew the syntax ... thank you :-)

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.