Reputation:
I want to add HTML elements in form of variable into an object by using JQuery *or without.
<a href="#" class="edit">EDIT</a>
Now I am just using this elements as variable...
var link = "<a href="+'"'+"#"+ '"'+ " class="+'"'+"edit"+'"'+">EDIT</a>";
Obj.addvariable(link) ????????? // This Object could be any ID Or Class Or Div
Upvotes: 1
Views: 6249
Reputation: 28755
You can use this in jquery as
$('#elementId').append(link); // with id
$('.elementClass').append(link); // with class, append to all elements of this class
Upvotes: 0
Reputation: 21449
you can add values to any properties even if they don't exist. javascript automatically creates them for you
Obj.anyProperty = 'new value';
if you want to append an element to a html element you can either use append:
$(element).append(link);
or appendTo:
$(link).appendTo(element)
Upvotes: 0
Reputation: 490263
$('body').append(link);
var element = document.createElement('a');
element.href = 'a';
element.className = 'b'
element.innerHTML = 'EDIT';
document.body.appendChild(element);
Upvotes: 1
Reputation: 39501
I don't exactly understand your question, but maybe jquery data is what you are looking for
Upvotes: 0