Hello I have a function that add combobox into the page, and I need to use the values of these combobox. When I try to acces into the jquery code it don't work. I think that I need to add the element to dom but I don't know how to do that. The id of combo is 'selectCombo'
Asked
Active
Viewed 1,435 times
3
-
Show us what you did so far regarding the code... – balexandre Sep 25 '11 at 11:36
-
2possible duplicate of [How do I add a DOM element with jQuery?](http://stackoverflow.com/questions/395525/how-do-i-add-a-dom-element-with-jquery) – Felix Kling Sep 25 '11 at 11:37
2 Answers
2
You have several choices:
- .prepend() http://api.jquery.com/prepend/
- .append() http://api.jquery.com/append/
- .insertAfter() http://api.jquery.com/insertAfter/
- .insertBefore() http://api.jquery.com/insertBefore/
-
-
true! "Add elements to the set of matched elements." -- jquery docs. removed it, thanks. – herkulano Sep 25 '11 at 13:02
0
Try this way:
$("<div/>", {
// PROPERTIES HERE
text: "Click me",
id: "example",
"class": "myDiv", // ('class' is still better in quotes)
css: {
color: "red",
fontSize: "3em",
cursor: "pointer"
},
on: {
mouseenter: function() {
console.log("PLEASE... "+ $(this).text());
},
click: function() {
console.log("Hy! My ID is: "+ this.id);
}
},
append: "<i>!!</i>",
appendTo: "body" // Finally, append to any selector
});

Re_p1ay
- 303
- 1
- 3
- 12