SHIN
SHIN

Reputation: 97

is it possible to change the css property of a class dynamically using jquery?

I have a class with css styles already defined. I am now trying to load that page as IFRAME in other site. I want to change the css property of that particular class from the loaded site. Is it possible with jquery. I tried from my end its not getting . can anyone help me...

Upvotes: 2

Views: 183

Answers (4)

Rituraj ratan
Rituraj ratan

Reputation: 10378

$(".classname").css("propertyname","setvalue");

example

$(".classname").css("height","50px");

for iframe use like

$("iframe").contents().find(".classname").css("propertyname","setvalue");

reference css

contains-selector

Upvotes: -2

Manwal
Manwal

Reputation: 23816

you can also use attr attribute to change value of specific attribute of Html.

$("img").attr("width","500");

Or

$("#tagid").attr("width","500");

or

$(".tagclass").attr("width","500");

But in one page you can't change property of child page which is loaded in IFRAME.

Upvotes: -1

jaydeep namera
jaydeep namera

Reputation: 1054

You can add or remove class using jquery as following way

$(".classname").addClass('new-classname');
$(".classname").removeClass('remove-classname');

Upvotes: -2

Michał Rybak
Michał Rybak

Reputation: 8706

You cannot change style of elements in iframe due to same-origin policy.

Upvotes: 7

Related Questions