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
393 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
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)

863 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

29 Experts available now in Live!

Get 1:1 Help Now