Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
-2
rated 0 times [  2] [ 4]  / answers: 1 / hits: 60910  / 13 Years ago, tue, november 29, 2011, 12:00:00

I'm trying to add a custom attribute on my element using jquery :



$('.map-areas-div').rand(numElements).each(function(){
$(this).attr('element_id',4);
});


But in the end, my elements doesn't have a element_id attribute.



PS, my html elements look like :



<div type=ground class=map-areas-div style=position: absolute; top: 900px; left: 720px; height: 40px; width: 90px;></div>


Thank you for help


More From » jquery

 Answers
4

You can't. Use jQuery.data api instead to associate custom properties with element's jQuery wrapper. http://api.jquery.com/jQuery.data/


[#88857] Sunday, November 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocky

Total Points: 316
Total Questions: 108
Total Answers: 110

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;