I have a page with multiple occurrences of an element with class of .gal_link, such as
<a href="" rel="shadowbox[gallery32];height=545;width=805" title="">Blah Blah</a>
What I am trying to do is find all occurrences of this on the page, and update the height and width to something like
<a href="" rel="shadowbox[gallery32];height=345;width=605" title="">Blah Blah</a>
I would imagine this should be easy but after searching high and low I can not find a straight forward way to do this. Any help would be appreciated.
I was able to alert the rel for each link upon a click but can't see how to change attribute values once the page has loaded.
$('.gal_link').click(function(){
var rel = $(".gal_link").attr('rel');
alert(rel);
});
Again thanks.
Using document. In JavaScript, the document. getElementsByTagName() method can be used to get the value of the rel attribute of a link or anchor tag. It takes a tag name in the parameter and returns an HTMLCollection, similar to a list or array.
The rel attribute specifies the relationship between the current document and the linked document. Only used if the href attribute is present. Tip: Search engines can use this attribute to get more information about a link!
The HTML <form> rel attribute is used to define the relationship between the current document and the linked document. The “rel” stands for relationship. It denotes that, we connect an external CSS with the HTML page. Syntax: <form rel="value">
Pass value you want to assign to attribute in second argument of attr( attributeName, value )
$("selector").attr('rel', 'somevalue');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With