I am using jQuery to append an element such as:
var mytop=100;
$(this).appendTo('.container')
.last()
.wrap('<div class="action" style="top:' + mytop + 'px;"></div>');
Only mytop
is a calculated number. Since the new element has the class action
, it should later change the top by adding a class moveup
, such as:
$('document').on('click', function(e){
if($(e.target).hasClass('action')){
$(this).addClass('moveup');
}
});
with the CSS as:
.moveup{
top:5px;
}
The problem is, the inline CSS of the appended <div>
overrides the class's CSS. When this newly created item is clicked, it should have its top set at 5px.
How do I override the inline CSS with the Class's CSS?