Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

Using jQuery how can I set font-weight to "normal" for all elements that have "font-family: 'Abril Fatface'"?

Using jQuery how can I set font-weight to "normal" for all elements that have "font-family: 'Abril Fatface'"?

thanks in advance
0
badwolfff
Asked:
badwolfff
  • 6
  • 5
1 Solution
 
leakim971PluritechnicianCommented:
first way :
http://jsfiddle.net/kz10rjq3/4/
<div class="fat">HELLO</div>
<div class="aero">HELLO</div>
<div class="fat">HELLO</div>
<div class="aero">HELLO</div>

Open in new window

$(".fat").css("font-weight","normal");

Open in new window

where :
.fat {
    font-family:Abril Fatface;
    font-weight:bold;
}
.aero {
    font-family:Arial;
    font-weight:bold;
}

Open in new window

0
 
leakim971PluritechnicianCommented:
second way :

jQuery(function($) {
    $("[style*='Abril Fatface']").css("font-weight","normal");
});

Open in new window


with :
<div style="font-family:Abril Fatface;font-weight:bold;">HELLO</div>
<div style="font-family:Arial;font-weight:bold;">HELLO</div>
<div style="font-family:Abril Fatface;font-weight:bold;">HELLO</div>
<div style="font-family:Arial;font-weight:bold;">HELLO</div>

Open in new window

0
 
badwolfffAuthor Commented:
Thanks
Is there a way to insert an !important too?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leakim971PluritechnicianCommented:
did yo utry :
$("[style*='Abril Fatface']").css("font-weight","normal !important");
0
 
badwolfffAuthor Commented:
Not working
The thing is that some elements use the abril fatface font and in the css selector just call the font.
Then separately some other CSS is setting certain elements as font-weight:bold
What I need to do is logically: for each element that uses Abril Fatface and also has font-weight:bold, set the font-weight to normal !important

do you think that is possible?

Sorry for the trouble
0
 
badwolfffAuthor Commented:
I think it's called a Multiple Attribute selector but I don't know how to use it
0
 
leakim971PluritechnicianCommented:
where to see that?
0
 
leakim971PluritechnicianCommented:
$("*").each(function() { 
        if( $(this).css("font-family").indexOf("Abril Fatface")>=0 ) { 
              $(this).css("font-weight","normal !important");; 
        } 
});

Open in new window

0
 
badwolfffAuthor Commented:
Yipppeee! It worked. I had to modify it a bit though :)

jQuery("*").each(function() { 
        if( jQuery(this).css("font-family").indexOf("Abril Fatface")>=0 ) { 
            jQuery(this).css({ "font-weight":"normal", "font-weight":"400" });
        } 
    });

Open in new window

0
 
badwolfffAuthor Commented:
You are on fire tonight!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now