I am trying to replace the text of a list element and maintain the stylying of the original class, however, when I replace it overwrites the CSS. When I try add new styling to it it doesn't seem to work. I may be mis-understanding the html() function - can it have styling applied to it?
$('#listElement>li:eq(1)').html('replacement text').addClass('.progressStep')
$('.progressStep').css({
'width': '140px',
'display': 'block',
'margin': '10px 0 0 -60px',
'color': '#c5c5c5'
})
You have passed .progressStep
as argument to .addClass()
. which is adding class .progressStep
and not progressStep
You do not need to use class selector in .addClass()
method. you should simply pass classname(s) as an argument. In current case, use addClass('progressStep')
instead of addClass('.progressStep')
:
$('#listElement>li:eq(1)').html('replacement text').addClass('progressStep')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments