Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  189] [ 5]  / answers: 1 / hits: 27309  / 14 Years ago, tue, october 5, 2010, 12:00:00

Well, I have this jQuery image slideshow that uses the attribute control inside an <a>. Seeing how it didn't validate I searched for a way to add this attribute inside my HMTL via jQuery but I didn't really find anything relevant. Now I don't really care about how valid my page is, but I'm really curious in how to add an HTML attribute inside an HTML tag.



In case I wasn't clear enough with my explanation, I have this code:



<a id=previous control=-6 href=#></a>


And I want to add control=-6 with jQuery.


More From » jquery

 Answers
42

Since the jQuery version has been well covered here, I thought I'd offer something different, so here a native DOM API alternative:



document.getElementById('previous').setAttribute('control','-6');


Yes, I know you asked for jQuery. Never hurts to know the native way too. :o)


[#95409] Saturday, October 2, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckenna

Total Points: 445
Total Questions: 109
Total Answers: 109

Location: Virgin Islands (U.S.)
Member since Sun, May 16, 2021
3 Years ago
;