Adding attribute on html element inside the iframe using jquery

I have this code for getting the attributes of an html element inside an iframe.

Code:

$("#frameID").contents().find("#htmlelementID").attr("myattr");

My dilemma here is i want to add a new attribute on the html element inside my iframe.

I'll truly appreciate every idea that will help me on this.

Upvotes: 0

Views: 4614

Answers (2)

Arun P Johny
Arun P Johny

Reputation: 388316

Use the setter version of .attr()

$("#frameID").contents().find("#htmlelementID").attr("newattr",  'newvalue');

Upvotes: 2

Rituraj ratan
Rituraj ratan

Reputation: 10378

by attr

$("#frameID").contents().find("#htmlelementID").attr("attrname",  'atrvalue');

by prop

$("#frameID").contents().find("#htmlelementID").prop("attrname",  'atrvalue');

Upvotes: 0

Related Questions