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
477 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
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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