I am trying to create 2 elemets, 1 with id and 1 without.
I have the following code and want to know how to simplify it. Any helps? Thanks a lot.
var element = $('<div/>').attr({'id': tool}).addClass('s-Tool')
.append(
$('<div/>').css({'padding': '0.5em 1em'}).html(text)
);
//only different is attr id
var elementClass = $('<div/>').addClass('s-Tool')
.append(
$('<div/>').css({'padding': '0.5em 1em'}).html(text)
);
1 Answer