Reputation: 7734
i have a little problem with jQuery. I want to append ID for element from other element after that i click on it... :) So, if i click some list element this element id will go to another, can you hel me? This is my code...
$('#main_menu li').click(function(){
(this.id).appendTo('.main_content ul')
})
Upvotes: 0
Views: 150
Reputation: 140228
Try appending the element itself:
$('#main_menu li').click(function() {
$(this).appendTo('.main_content ul')
});
Demo http://jsfiddle.net/AbeyT/
Upvotes: 0
Reputation: 87073
$('#main_menu li').click(function(){
$('.main_content ul').attr('id', this.id);
});
Here this.id
will get the clicked element id
and set that id
to .main_content ul
.
id
duplication, which is not allowed.Instead of id
you can make class
:
$('#main_menu li').click(function(){
$('.main_content ul').attr('class', this.id);
});
Upvotes: 2