Solved

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

Posted on 2014-09-03
11
375 Views
Last Modified: 2014-09-03
Using jQuery how can I set font-weight to "normal" for all elements that have "font-family: 'Abril Fatface'"?

thanks in advance
0
Comment
Question by:badwolfff
  • 6
  • 5
11 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40302539
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
 
LVL 82

Expert Comment

by:leakim971
ID: 40302540
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
 

Author Comment

by:badwolfff
ID: 40302578
Thanks
Is there a way to insert an !important too?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40302581
did yo utry :
$("[style*='Abril Fatface']").css("font-weight","normal !important");
0
 

Author Comment

by:badwolfff
ID: 40302584
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:badwolfff
ID: 40302586
I think it's called a Multiple Attribute selector but I don't know how to use it
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40302587
where to see that?
0
 

Author Comment

by:badwolfff
ID: 40302591
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40302599
$("*").each(function() { 
        if( $(this).css("font-family").indexOf("Abril Fatface")>=0 ) { 
              $(this).css("font-weight","normal !important");; 
        } 
});

Open in new window

0
 

Author Comment

by:badwolfff
ID: 40302611
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
 

Author Comment

by:badwolfff
ID: 40302612
You are on fire tonight!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now