Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
504 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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
 

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
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

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.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

661 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