Topic: Remove CSS style with jQuery (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31295" title="Pages that link to Topic: Remove CSS style with jQuery (Page 1 of 1)" rel="nofollow" >Topic: Remove CSS style with jQuery <span class="small">(Page 1 of 1)</span>\

 
Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 09-05-2009 01:44

Hi,

I have a wordpress theme where the post content div has a class in the stylesheet called ".post_content img" that styles the images in that div. On certain pages I don't want that style. Is there a way with jQuery to remove that css styling that the external stylesheet calls out at the time the page loads with the document.ready function?

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 09-05-2009 02:19

assuming "img" is the class you want removed:

code:
$(document).ready(function(){
   $("div.img").removeClass("img");
});


should do it...

Or, if you want to simply alter the css

code:
$(document).ready(function(){
   $("div.img").css("attribute", "value");
});



And, if you need to get the image itself and not the div, then


code:
$("div.img img")


will get you the image...

(Edited by DL-44 on 09-05-2009 02:22)

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 09-05-2009 05:00

Thank you for your guidance...you got me thinking in the right direction and I fixed the code. It actually turned out to be this:

code:
$(document).ready(function(){
   $(".post_content").removeClass("post_content img");
});

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 09-05-2009 17:20

I've found these articles to be extremely helpful for this kind of thing:
http://www.learningjquery.com/2006/11/how-to-get-anything-you-want-part-1
http://www.learningjquery.com/2006/12/how-to-get-anything-you-want-part-2

the code posted above was simply a "plug in your class/element here" example...

(Edited by DL-44 on 09-05-2009 19:07)

SleepingWolf
Paranoid (IV) Inmate

From:
Insane since: Jul 2006

posted posted 09-07-2009 06:29

Why not just create a page template for those pages (based on index.php or single.php)?
The page template could have its own css or it could share it with a master css file.
Just curious why this should be scripted.

Nature & Travel Photography
Main Entrance

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 09-12-2009 15:03

As SleepingWolf said, using JS and especially a whole framework to do this seem terribly inefficient and the wrong tool to do the job. Surely you can make another template or tweak the template of these pages to add the single line of CSS to do what you want.

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

posted posted 05-31-2011 11:04
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu