Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - With click of a link copy all classes from one element to another

(see jsfiddle example)

When the ".link_to_rule_them_all" is clicked i would like to copy all the '.link_to_rule_them_all span' classes into #box and clear the '#box' between every click.

my example code and the explanation is here http://jsfiddle.net/znCmq/2/

As you can see i have no idea about the js of this.. any ideas? eh..

like image 953
Joonas Avatar asked Dec 06 '22 22:12

Joonas


1 Answers

$('.link_to_rule_them_all').bind('click', function(e) {
    e.preventDefault();
    $('#box').attr('class', ($('span', $(this)).attr('class')));
});

live example : http://jsfiddle.net/moeishaa/3t33d/

like image 143
moe Avatar answered Apr 20 '23 17:04

moe